[Python-Dev] os.access versus os.exist
Guido van Rossum
gvanrossum at gmail.com
Mon Nov 15 21:51:44 CET 2004
> It would be awfully nice (on posix platforms, for my use-case) to find
> out whether a file is inaccessible due to permission restrictions, or
> due to non-existence.
Why can't you solve this by doing a stat() when access() returns False?
Also, in general I recommend against using access() except for setuid
apps that need to test whether the *real* user id has the desired
access; there are many additional reasons why opening a file fails
even though access() returns True; amongst the causes can be race
conditions (the file was changed after you called access() or
conditions like ETXTBSY (you can't write an executable file that is
being executed) or ENOMEM (a kernel resource problem).
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev