[Tutor] Test for file existance

Klas Marteleur klas.martelleur at telia.com
Mon Aug 30 19:20:29 CEST 2004


I wanna test for file existance using os.access
I have tried the following but none seem to work

os.access("/home/klas/epa.txt", F_OK)
os.access("/home/klas/epa.txt", f_ok)
os.access("/home/klas/epa.txt", "F_OK")
os.access("/home/klas/epa.txt", "f_ok")

but i get the following error:

Traceback (most recent call last):
  File "<pyshell#156>", line 1, in ?
    kalle = os.access("/home/klas/epa.txt",F_OK)
NameError: name 'R_OK' is not defined

or

Traceback (most recent call last):
  File "<pyshell#157>", line 1, in ?
    kalle = os.access("/home/klas/epa.txt",'f_ok')
TypeError: an integer is required

... does python want me to put a inter in "f_ok" place.. i dont understand....

Klas


More information about the Tutor mailing list