[Python-Dev] Returning Windows file attribute information via os.stat()
MRAB
python at mrabarnett.plus.com
Tue Jun 10 14:03:14 CEST 2014
On 2014-06-10 05:02, Ben Hoyt wrote:
[snip]
>
> FILE_ATTRIBUTE_HIDDEN = 2 # constant defined in Windows.h
>
> def is_hidden(path):
> if startswith(os.path.basename(path), '.'):
> return True
> st = os.stat(path)
> if hasattr(st, 'st_winattrs') and st.st_winattrs & FILE_ATTRIBUTE_HIDDEN:
That could be written more succinctly as:
if getattr(st, 'st_winattrs', 0) & FILE_ATTRIBUTE_HIDDEN:
> return True
> return False
>
More information about the Python-Dev
mailing list