A little disappointed so far

Tim Peters tim.one at comcast.net
Sun May 18 21:08:30 EDT 2003


[Graham Nicholls]
> Is there an equivalent of [ -f $filename ] to test for the existence
> of filename in Python?

Try os.path.exists(filename).  If in addition you care whether it's a
directory or non-directory file, isdir() or isfile() instead.  These are
convenience functions wrapping os.stat(filename).






More information about the Python-list mailing list