How to tell if I can open a file or not

Wim Lavrijsen wlav at hpatl26.cern.ch
Thu Jun 8 10:15:52 EDT 2000


"Skip Hollowell" <thollowe at opentext.com> writes:

>Is there a way I can check the attrbutes of the file before I open it?

>>> os.access( fileName, os.R_OK )

Similarly os.W_OK, os.X_OK (as expected) and os.F_OK to test the existence.
Returns '1' for success, '0' for failure. Works on files and paths.

Best regards,
       Wim Lavrijsen



More information about the Python-list mailing list