[Tutor] Checking file existance

Scot W. Stevenson scot@possum.in-berlin.de
Fri, 23 Aug 2002 07:00:00 +0200


Hi there, 

> import os.path
>
> if os.path.exists(filename):
>   print "found it"

There seems to be a second way: 

import os
if os.access(filename, os.F_OK):
    print "found it"

os.access will also let you test for read, write, and execute permissions. 
No idea why this is duplicated, but there you go.

Y, Scot

-- 
   Scot W. Stevenson wrote me on Friday, 23. Aug 2002 in Zepernick, Germany   
       on his happy little Linux system that has been up for 1588 hours       
        and has a CPU that is falling asleep at a system load of 0.07.