[Python-Dev] os.access versus os.exist

Robert Brewer fumanchu at amor.org
Mon Nov 15 22:36:24 CET 2004

I wrote:
> > 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.

Guido van Rossum replied:
> Why can't you solve this by doing a stat() when access() 
> returns False?

In my current case, stat() gives an error (even though the file exists):

OSError: [Errno 2] No such file or directory:

Running the same stat() call in the interpreter (as opposed to inside my
mod_python app) gives no such error; I get normal stat output, so the
file does exist. I figured since the app was running as LocalSystem it
was a permissions issue. [One quick sanity check later] Yes, if I run
Apache2 under my account, stat() does not error.

Hm. I see now I'm following the wrong issue. It has more to do with how
Windows shares mapped drives between users (it doesn't). If I use the
UNC path, I don't have an issue.

Thanks for pointing me away from the wrong direction. ;)

Robert Brewer
Amor Ministries
fumanchu at amor.org

More information about the Python-Dev mailing list