using os.chmod in windows

David LeBlanc whisper at oz.net
Wed Jun 19 20:43:17 EDT 2002


I didn't find any doc for this, so I tried the simple expedient of:

# Attrtest.py

import os

os.stat('testfile.txt')

raw_input('Change file attribute using File Explorer, then press return')

os.stat('testfile.txt')

When I did this, I got:

(At the start, normal r/w file)
>>> os.stat('testfile.txt')
(33206, 0L, 9, 1, 0, 0, 26L, 1024026085, 1023320564, 1023320564)
(Add hidden attribute using File Explorer)
>>> os.stat('testfile.txt')
(33206, 0L, 9, 1, 0, 0, 26L, 1024532993, 1023320564, 1023320564)
(Add readonly in addition to hidden)
>>> os.stat('testfile.txt')
(33060, 0L, 9, 1, 0, 0, 26L, 1024532997, 1023320564, 1023320564)

Notice that the last five digits (an int in decimal) of the 8th group have
changed. How you parlay that into something chmod() can use, I have no idea.

HTH,

David LeBlanc
Seattle, WA USA

> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of Locke
> Sent: Wednesday, June 19, 2002 15:59
> To: python-list at python.org
> Subject: using os.chmod in windows
>
>
> I never really learned the number codes for file permissions in UNIX. I
> always just did "chmod +r" because it is much easier to remember. I need
> to change a file to be 'hidden' in windows. In UNIX, this is done by
> renaming it with a dot in front of the name. But the python os.chmod
> command says you need to specify the number as the argument. As far as I
> know, there is no number for 'hidden' since it is windows only. So how
> do I do this?
>
> Thanks.
>
> --
> http://mail.python.org/mailman/listinfo/python-list






More information about the Python-list mailing list