James said the following on 4/12/2005 11:00 PM:
Is it possible to check if you have permission to access and or change a
directory or file?


James - You can use the access() in the os module.

import os

print os.access('C:\\', os.R_OK | os.W_OK) # check for read/write access
# hopefully print True
print os.access('C:\\noexist.file', os.R_OK) # Check no existent file
# will print False
print os.access('C:\\Docume~1\\anotheruser\\Mydocu~1', os.R_OK) # Read another users documents folder
# should print False if no read access


Please read http://docs.python.org/lib/os-file-dir.html for more info.

Thanks,
-Kartic
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to