how do i check if a file exists with python?

Alex Martelli aleaxit at yahoo.com
Tue Jan 2 16:23:12 EST 2001


"Moshe Zadka" <moshez at zadka.site.co.il> writes:

> > When somebody asks how to determine whether a file exists, it IS quite
> > likely that what they mean is something different
> ...
> > It's unlikely, although of course possible, that 'actual existence'
> > is exactly what one needs to determine
> 
> In that case, on a typical OS (even Windows-like, although it's more
> pronounced on UNIX) one *can't* know the answer, in general. Consider
> stuff like unreadable directories, for example.

It may need sufficient privilege to determine existence, but a nastier
problem is with removable and network-mounted media -- tough
indeed to distinguish between "doesn't exist" and "does exist but it
just can't be reached right now".


Alex



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com





More information about the Python-list mailing list