How can I get the Unix permission mask from a file? [duplicate]
os.stat is a wrapper around the stat(2) system call interface. >>> import os >>> from stat import * >>> os.stat(“test.txt”) # returns 10-tupel, you really want the 0th element … posix.stat_result(st_mode=33188, st_ino=57197013, \ st_dev=234881026L, st_nlink=1, st_uid=501, st_gid=20, st_size=0, \ st_atime=1300354697, st_mtime=1300354697, st_ctime=1300354697) >>> os.stat(“test.txt”)[ST_MODE] # this is an int, but we like octal … 33188 … Read more