This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author scrool
Recipients scrool
Date 2020-05-16.11:44:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I'm using Windows and lets' say I have this directory structure listed with cmd:

> dir /A

16.05.20  11:15    <DIR>          directory
16.05.20  10:47                 0 hidden
16.05.20  11:25    <SYMLINK>      link [regular]
16.05.20  10:47                 0 readonly
16.05.20  11:15                 0 regular
16.05.20  10:48                 0 system


or PowerShell:

PS > dir -Force

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----          16.5.20     11:15                directory
-a-h--          16.5.20     10:47              0 hidden
-a---l          16.5.20     11:25              0 link
-ar---          16.5.20     10:47              0 readonly
-a----          16.5.20     11:15              0 regular
-a--s-          16.5.20     10:48              0 system

or attrib:

> attrib
A   H                hidden
A                    link
A    R               readonly
A                    regular
A  S                 system

I'd like to print file attributes in a text form. If I use stat.filemode():

>>> import os, stat
>>> print("\n".join(["{} {}".format(stat.filemode(os.stat(n).st_mode), n) for n in os.listdir('.')])) 
drwxrwxrwx directory
-rw-rw-rw- hidden
-rw-rw-rw- link
-r--r--r-- readonly
-rw-rw-rw- regular
-rw-rw-rw- system

not surprisingly I miss all windows attributes. On the top of that I get only values of stat.S_IWRITE and stat.S_IREAD as documented in os.chmod().

I'd like to have a new function, let's say fileattributes() which would behave like this:

>>> print("\n".join(["{} {}".format(stat.fileattributes(os.stat(n).st_file_attributes), n) for n in os.listdir('.')]))
d----- directory
-a-h-- hidden
-a---l link
-ar--- readonly
-a---- regular
-a--s- system

In this example I have used same format of attributes as in PowerShell because it is most similar to filemode().

I guess link cannot be currently identified with contants in stat module.
Date User Action Args
2020-05-16 11:44:47scroolsetrecipients: + scrool
2020-05-16 11:44:47scroolsetmessageid: <>
2020-05-16 11:44:47scroollinkissue40644 messages
2020-05-16 11:44:46scroolcreate