FInding files with python

Fredrik Lundh fredrik at pythonware.com
Sun Oct 28 04:36:14 EST 2001


"Widgeteye" <Widgeteye at widgets.com> 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):
    ...

</F>

<!-- (the eff-bot guide to) the python standard library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->





More information about the Python-list mailing list