[Tutor] file?

Kent Johnson kent37 at tds.net
Tue Apr 4 04:41:45 CEST 2006

kakada wrote:
> Hi all,
> How can we know that one specific file is already exist in filesystem?
> for instance, I want to read zipfile by issuing code:
> import zipfile
> ziparchive = zipfile.ZipFile(inputfilename, "r")
> if the inputfilename doesn't exist then an error would be occurred.
> I want to catch up this special case first.

if os.path.isfile(inputfilename):
   # file exists


More information about the Tutor mailing list