Understanding CHMOD

Fuzzyman michael at foord.net
Fri Feb 13 03:55:30 EST 2004


Ok.... so I might be a windoze user trying to program CGIs for a Linux
server.... but Python doesn't seem to go out of it's way to make
understanding file attributes difficult. The python manual is
appalling in this are a :-(

Anyway - I think I've finally worked out that the correct way to get
(rather than set) the mode of a file is :

from stat import *
S_IMODE(os.stat(filepath)[ST_MODE])

Obvious huh !

The result will be some bitmasked combination of the following ?

statlist = [S_ISUID, S_ISGID, S_ENFMT, S_ISVTX, S_IREAD, S_IWRITE,
S_IEXEC, S_IRWXU, S_IRUSR, S_IWUSR, S_IXUSR, S_IRWXG,
 S_IRGRP, S_IWGRP, S_IXGRP, S_IRWXO, S_IROTH, S_IWOTH, S_IXOTH]

Which mean ??????

Having obtained a result from S_IMODE(os.stat(filepath)[ST_MODE]), how
do I work out what it means ?

Thanks.

Fuzzy

http://www.voidspace.org.uk/atlantibots/pythonutils.html



More information about the Python-list mailing list