Yann Leboulanger wrote: > Martin v. Löwis a écrit : >>> 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 !! >> This description is, unfortunately, too imprecise to allow reproducing >> that effect. What precisely do you mean by "I move My Documents to >> this e:\test folder"? >> > > > I Right click on "My Documents" folder, and change the path to e:\test > there. > So that "My documents" folder points to e:\test
Python uses the GetFileAttributesW API call to determine access to the path you pass in. It then tests the return against the FILE_ATTRIBUTE_READONLY flag and returns False if you asked for Write and the Readonly flag is set. The problem seems to be twofold: whereas a normal directory (such as e:\temp) will not usually have its readonly flag set, on a special directory such as the My Documents folder the flag seems to be set by the system; also, the READONLY flag on a directory refers to its deleteability, not to its writeablility. At least, according to: http://msdn2.microsoft.com/en-us/library/aa364944.aspx I suspect this constitutes a bug in os.access which should do some more interpretation of the results. But no doubt Martin von L can comment with more authority than I on this one. TJG -- http://mail.python.org/mailman/listinfo/python-list