FInding files with python

Fredrik Lundh fredrik at
Sun Oct 28 10:36:14 CET 2001

"Widgeteye" <Widgeteye at> wrote:
> I'm trying to figure out how you would test for the existence
> of a file on your drive in python.
> I want to write a little program that does the following:
> If (file exists)
>   do the following

import os

# check if there's a file with this name
if os.path.isfile(filename):

# check if there's anything with this name
if os.path.exists(filename):


<!-- (the eff-bot guide to) the python standard library:

More information about the Python-list mailing list