Tuesday, June 26, 2007

python : Change file attributes on Windows

I was too lazy to register here to correct recipe for setting file atttibutes with Python on windows, so I just blog it. You will need pywin32 module and some precautions, because you probably want to avoid cases when your cross-platform application fails due to the absence of some windows-specific stubs.

try:
import win32file
win32file.SetFileAttributes(report_name, win32file.FILE_ATTRIBUTE_HIDDEN)
except ImportError:
pass