Testing for a file in python?

Harry George hgg9140 at seanet.com
Mon Jun 12 18:44:16 EDT 2000


If you use pyperl, you get:

  import pyperl
  p=pyperl.PyPerl()
  ...
  if p.f(filename):
    ...

Similarly the vaious other file operators.

See: http://www.seanet.com/~hgg9140/comp/index.html

olczyk at interaccess.com (Thaddeus L. Olczyk) writes:

> How would you go about testing if a certain file exists in python?
> In most scripting languages you have the -f test:
> 
> if -f filename do
>    whatever_you_were_going_to_do
>    fi
> else do
>    print "Error" file not found
>    fi
> 
> stat doesn't work, it aborts if the file does not exist.

-- 
Harry George
hgg9140 at seanet.com



More information about the Python-list mailing list