alan.gauld at freenet.co.uk
Tue Apr 4 09:47:07 CEST 2006
> How can we know that one specific file is already exist in filesystem?
> for instance, I want to read zipfile by issuing code:
Take a look in the os.path module.
There is explanation of how to check for various aspects of files
(including existence) in my web tutor Operating System topic.
> if the inputfilename doesn't exist then an error would be occurred.
> I want to catch up this special case first.
The other approach, implied in your question is simply to
*try* to *open* for read:
except IOError: # it presumably didn't exist, so deal with it
Author of the learn to program web tutor
More information about the Tutor