os.access() under windows
Yann Leboulanger
yann.le_boulanger at u-paris10.fr
Sun Dec 2 09:14:08 EST 2007
David Tweet wrote:
> To answer indirectly, usually the EAFP (easier to ask forgiveness than
> permission) approach works better for this kind of thing.
>
> try:
> f = open('e:\\test\\test', 'a')
> f.write('abc')
> f.close()
> except IOError:
> print "couldn't write test file, continuing..."
>
> On Dec 1, 2007 1:48 AM, Yann Leboulanger <yann.le_boulanger at u-paris10.fr> wrote:
>> Hi,
>>
>> Under Windows XP os.access has a strange behaviour:
>>
>> I create a folder test under e:
>>
>> then os.access('e:\\test', os.W_OK) returns True. Everything's ok.
>>
>> Now I move My Documents to this e:\test folder
>>
>> Then os.access('e:\\test', os.W_OK) returns False !!
>>
>> but this works:
>> f = open('e:\\test\\test', 'a')
>> f.write('abc')
>> f.close()
>>
>> So why os.access returns False ?
>>
>> --
>> Yann
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>
yep but the test file I try to create to know if I can write there may
be a folder for exemple, and the open() will fail.
So this can be considered as a bug in os module?
More information about the Python-list
mailing list