check file exists

Andre van Straaten andre at UltraShell.Net
Mon Jul 31 17:44:47 EDT 2000


Randy Heiland <heiland at ncsa.uiuc.edu> wrote:
> How does one test for whether or not a (Unix) file exists?

> thanks,
> Randy

I use generally something like this:

# check if in_file exists
if (0 == os.path.isfile(sys.argv[1]) or
    (0 == os.stat(sys.argv[1])[stat.ST_SIZE])):           # if filesize = 0
    print "no valid input file\n"
else:


-- avs 

Andre van Straaten
http://www.vanstraatensoft.com
______________________________________________
flames please to /dev/null at vanstraatensoft.com




More information about the Python-list mailing list