A little disappointed so far

Erik Max Francis max at alcyone.com
Sun May 18 20:56:58 EDT 2003


Graham Nicholls wrote:

> Is there an equivalent of [ -f $filename ] to test for the existence
> of
> filename in Python?  Things like this seem essential for a shell tool
> language.

os.access would probably be the most obvious function.  You're probably
better off trying to use the file and catching the error should it not
exist, rather than testing for its existence and then doing something
with it as separate actions to avoid potential race conditions (this is
a general issue, not Python-specific).

-- 
   Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ I get my kicks above the wasteline, sunshine
\__/  The American, _Chess_




More information about the Python-list mailing list