os.mkdir and mode

Peter Otten __peter__ at web.de
Sat Dec 2 03:52:39 EST 2006


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.

Peter



More information about the Python-list mailing list