os,access argument problem
David Bolen
db3l at fitlinxx.com
Tue Aug 22 17:56:37 EDT 2000
Bob van der Poel <bvdpoel at uniserve.com> writes:
> 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
os.access takes the arguments (path, mode). Mode should be a numeric
file mode , so the TypeError is because you are trying to supply a
string.
If you just want to test for existence, use 0 (numeric) for the mode.
You can use the symbolic values (e.g., "F_OK") but you need to use
them as defined by the os module, for example:
os.access(newfile,os.F_OK)
if you print it out, you'll find that os.F_OK is defined as 0.
--
-- David
--
/-----------------------------------------------------------------------\
\ David Bolen \ E-mail: db3l at fitlinxx.com /
| FitLinxx, Inc. \ Phone: (203) 708-5192 |
/ 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \
\-----------------------------------------------------------------------/
More information about the Python-list
mailing list