best way to check if a file exists?

Fredrik Lundh fredrik at pythonware.com
Wed Nov 1 21:06:00 CET 2006


wittempj at hotmail.com wrote:

> os.path.exists() checks if a path exists, so a directory as argument
> also returns True

the original requirement was "to check if a file of a certain name 
exists before the user creates a new file of that name".

if you want to check for files only, use the os.path.isfile predicate.

</F>




More information about the Python-list mailing list