Python - Test directory permissions

Posted by Sean on Stack Overflow See other posts from Stack Overflow or by Sean
Published on 2009-02-11T22:26:47Z Indexed on 2010/03/15 8:29 UTC
Read the original article Hit count: 388

Filed under:
|
|
|

In Python on Windows, is there a way to determine if a user has permission to access a directory? I've taken a look at os.access but it gives false results.

>>> os.access('C:\haveaccess', os.R_OK)
False
>>> os.access(r'C:\haveaccess', os.R_OK)
True
>>> os.access('C:\donthaveaccess', os.R_OK)
False
>>> os.access(r'C:\donthaveaccess', os.R_OK)
True

Am I doing something wrong? Is there a better way to check if a user has permission to access a directory?

© Stack Overflow or respective owner

Related posts about python

Related posts about Windows