Getting File Permissions

Juho Schultz juho.schultz at helsinki.fi
Tue Mar 7 08:54:09 EST 2006


Hari wrote:
> Hi,
> For getting permissions of a file, the following script has been
> suggested in the same group
> 
> import os, stat
> st = os.stat(myfile)
> mode = st[stat.ST_MODE]
> print "mode is", octal(mode & 0777)
> 
> But while executing I am getting error message as follows
> 
> Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
> NameError: name 'octal' is not defined
> 
> Since I am new to python, can any one help me to solve this error?
> A bunch of thanks in advance.
> 
> Hari
> 

You can use "oct" instead of "octal".



More information about the Python-list mailing list