os.access() under windows

Yann Leboulanger asterix at lagaule.org
Mon Dec 3 10:50:20 EST 2007


Tim Golden a écrit :
> Well, that's not the case for files: if you set your
> file's readonly attribute to True, then os.access (W_OK)
> will return False and you won't be able to write to the
> file:


> The only issue (at least, the only one we're discussing here) is:
> If os.W_OK on a directory returns True, that won't stop you writing
> into that directory.
> 


> 
> To be precise: open () on a file within that directory doesn't fail.

Yep sorry I was a bit too expeditive :)

> Personally, I sympathise with you here. Python comes from a Unix
> background and, unsurprisingly, it offers all the major Unix
> system calls. Since Windows historically offered a Posix layer
> which mapped them to *something*[1], the developers simply called
> those under the covers. And the basic policy was: whatever Windows
> passes back to Python, Python passes on to you.
> 
> Later (mid-2006, I think) some or all of these Posix-layer functions
> were replaced by native Win32 APIs. At that point, it arguably became
> Python's responsibility to define semantics. But it's a fuzzy sort of
> area. I think a doc patch which said something like: "Calls
> FileGetAttribute[A|W] and compares against FILE_READONLY_ATTRIBUTE"
> might meet the case, although a bit of a cop-out.
> 

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

-- 
Yann



More information about the Python-list mailing list