os.mkdir and mode

Nick Craig-Wood nick at craig-wood.com
Sat Dec 2 05:30:05 EST 2006


Peter Otten <__peter__ at web.de> wrote:
>  vj wrote:
> 
> > How do I do the following unix command:
> > 
> > mkdir -m770 test
> > 
> > with the os.mkdir command. Using os.mkdir(mode=0770) ends with the
> > incorrect permissions.
> 
>  mkdir() works just like its C equivalent, see
>  http://docs.python.org/dev/lib/os-file-dir.html:
> 
>  "Where it is used, the current umask value is first masked out."
> 
>  Use os.chmod() after os.mkdir() to get the desired permissions.

I think you meant use os.umask(0) before the os.mkdir() ?

-- 
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick



More information about the Python-list mailing list