chmod g+ Equivalent

Lawrence Oluyede raims at dot.com
Mon Aug 13 18:33:01 EDT 2007


milan_sanremo <hancock.robert at gmail.com> wrote:
> I've read the documentation on os.chmod() and can implement all the
> standard commands, but what is the syntax for the equivalent of chmod g
> + to set the group id?

chmod() [1] takes as the second parameter a bitwise or-ed combination of
a series of values. If you look at chmod's man page ("man 2 chmod" on
the shell) you can see the following values for the group id (I have OSX
so the actual value may be different on your OS):

           #define S_IRWXG 0000070    /* RWX mask for group */
           #define S_IRGRP 0000040    /* R for group */
           #define S_IWGRP 0000020    /* W for group */
           #define S_IXGRP 0000010    /* X for group */

So you just have to OR them to accomplish your goal.  

1 - <http://docs.python.org/lib/os-file-dir.html#l2h-2677>

-- 
Lawrence, oluyede.org - neropercaso.it
"It is difficult to get a man to understand 
something when his salary depends on not
understanding it" - Upton Sinclair



More information about the Python-list mailing list