[Tutor] file permissions

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Wed Dec 7 20:52:20 CET 2005



On Wed, 7 Dec 2005, Eric Walker wrote:

> Looking for easiest way to get a files permissions in linux.

Hi Eric,

What have you looked at so far?

One of the first hits to the Google query "file permission python"  comes
up with some good information:

    http://www.faqts.com/knowledge_base/view.phtml/aid/5707/fid/552

Forgive me: I'm giving you a hard time only because it didn't look like
you did anything yourself yet.  Next time you ask a question, also try to
show what you've tried so far to find an answer, so that we know we're not
following avenues that you've already pursued.

We want to make sure you know how to look for answers.  If the existing
documentation sucks (and some of Python's documentation does need more
work!), then we want to know that too so that we can help improve it by
sending comments to the Documentation team.


In summary, there's file permission stuff we can extract using the
'stat()' function in the 'os' module:

    http://www.python.org/doc/lib/os-file-dir.html#l2h-1629

The values we get back from os.stat() are a little obscure, but we can
interpret the results using the 'stat' module:

    http://www.python.org/doc/lib/module-stat.html

I'm not sure if there's nicer interface to the permission bits; most
material I see on it looks fairly low-level.


If you have more questions, please feel free to ask.  (But please show
what work you've tried so far; that way, we have a better idea of your
context.)  Good luck!



More information about the Tutor mailing list