How to control permission of file?

Grant Edwards grante at
Fri Jun 30 23:53:52 CEST 2006

On 2006-06-30, Schüle Daniel <uval at> wrote:

>> When one open()s a file (that doesn't exist) for writing , how
>> does one control that file's permissions (it's "mode" in Unix
>> terms).
> what do you mean by "contor file's mode"?

Are you asking what a file's mode is?  

Under Unix, it's a bitmapped value that determines what the
access permissions are for the file. There are individual bits
that enable permissions for user-read, user-write,
user-execute, group-read, group-write, group-execute,
other-read, other-write, other-execute, etc.

If you look at there's a "mode" parameter (the same
as the mode parameter in Unix's libc open()).  I wanted to know
how to control a file's mode when it was created by the builtin

I'm afraid I don't know how else to say it.

> usually you try to open and if you are not allowed you will
> get the exception
> >>> try:
> ...     f = file("/etc/shadow")
> ...     print
> ... except IOError, e:
> ...     print e
> ...
> [Errno 13] Permission denied: '/etc/shadow'
> >>>

True, but I don't see what it has to do with my question.

> if you want to know more about file attributes

Um, thanks. I know all about file attributes.

Grant Edwards                   grante             Yow!  Inside, I'm already
                                  at               SOBBING!

More information about the Python-list mailing list