why not this import os from sys import platform if platform == "win32": os.system("attrib +h c:\\spam.txt")