I want to delete the file filename if it exists. Is it proper to say
filename
if os.path.exists(filename): os.remove(filename)
Is
A KISS offering:
def remove_if_exists(filename): if os.path.exists(filename): os.remove(filename)
And then:
remove_if_exists("my.file")