Python and file attributes

Corinna Vinschen corinna-cygwin@cygwin.com
Mon Jul 29 08:06:00 GMT 2019


On Jul 28 18:12, Steven Penny wrote:
> The Windows version of Python can access file attributes:
> 
>    >>> import os
>    >>> os.stat('C:\Recovery').st_file_attributes
>    8214
> 
> https://docs.python.org/library/os#os.stat_result.st_file_attributes
> 
> However the Cygwin version cannot:
> 
>    >>> import os
>    >>> os.stat('C:\Recovery').st_file_attributes
>    Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
>    AttributeError: 'os.stat_result' object has no attribute
>    'st_file_attributes'
> 
> This is unexpected as other Cygwin tools can access this information:
> 
>    $ lsattr
>    -hs------n-- ./Recovery

No, it's not unexpected.  Attributes are new since Cygwin 3.0 so this
would have required a python rebuild. The Cygwin utilities lsattr/chattr
are very likely the *only* tools being able to access these attributes
at this time.


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20190729/096fce52/attachment.sig>


More information about the Cygwin mailing list