exception just to avoid output error (newbie)

Flyzone flyzone at technologist.com
Wed Apr 18 05:13:18 EDT 2007


Hi
I'm trying to delete some files, but i get an exception error if the
file don't exist.
I can use an {if fileexist(file) then delete}, but it will get cpu
time.
So i catch the exception with:
       try: os.remove(filename)
       except EnvironmentError: error=1
If i just want to avoid the output error, is this the right way to
write the code?
I don't care of get if is in error, but an "except EvironmetError"
without the ":" will give me a sytax error.
Am I too much complicated? :-)

Thanks in advance




More information about the Python-list mailing list