#!/usr/bin/python import os myfile="/tmp/foo.txt" ## If file exists, delete it ## if os.path.isfile(myfile): os.remove(myfile) else: ## Show an error ## print("Error: %s file not found" % myfile)