os,access argument problem
Matthew Schinckel
matt at null.net
Tue Aug 22 09:42:45 EDT 2000
In message <39A02CE2.CFE1BE01 at uniserve.com>, Bob van der Poel wrote:
>
>
> I want to test for the existance of a file, so I:
>
> if os.access(newfile, 'F_OK'):
>
> However, I get the error message:
>
> TypeError: illegal argument type for built-in operation
>
> Something wrong with the 'F_OK' I presume. Can't figure out what to
> change it to....
>
You might want to try a different method:
try:
file = open(filename,'r')
except IOError:
print "File does not exist"
# Act on the open file
file.close()
Or, perhaps:
import os
print os.path.isfile(filename)
may be more useful.
--
Matthew Schinckel <matt at null.net>
More information about the Python-list
mailing list