os.access() under windows

Tim Golden mail at timgolden.me.uk
Mon Dec 3 11:10:10 EST 2007


Yann Leboulanger wrote:
> Ok thanks for all those information, I'll remove the call to os.access() 
> on folders for windows in my application.
> 

FWIW, I think it's worth bearing in mind what was said
earlier in this thread: it's easier to ask forgiveness
than permission. Technically, even if os.access did
exactly what you expected, there's nothing to stop the
access changing between os.access (...) and open (...).
Unless you have reason not to, it's considered perfectly
good practice in Python to try/except the open ():

<code>
try:
   f = open ("e:/test/test.tst", "w")
except (IOError, WindowsError):
   print "Something went wrong"
else:
   "Do whatever"
</code>

TJG



More information about the Python-list mailing list