[Tutor] puzzled by modes in os.mkdir()

Karl Pflästerer sigurd at 12move.de
Mon Apr 5 20:50:04 EDT 2004

On  6 Apr 2004, Brian van den Broek <- bvande at po-box.mcgill.ca wrote:

> mkdir( path[, mode])
> Create a directory named path with numeric mode mode. The default
> mode is 0777 (octal). On some systems, mode is ignored. Where it
> is used, the current umask value is first masked out.
> Availability: Macintosh, Unix, Windows.

> This is opaque to me, I am afraid.

> Here are my questions:

> 1) Are the modes here referred to the same ones as it the stat
> module? They don't seem to me to be, but the description of
> os.cmod(path, mode) references stat and nothing else.

You're right they are different.

> 2) Either way, I'd appreciate a pointer on what to read so that I
> can understand the Lib Ref's description of mkdir. (I don't know
> what is going on well enough to do a fruitful google-search.) In
> particular, I need to know what "0777 octal" means. (Knowing about
> the other options would be nice, too.)

You should know Linux/Unix for that.  In these systems the file access
permissions can be defined for the different groups: the user (the owner
of the file), the group (the user group the file owner belongs to) and
other (which means all users which are not part of the two other
groups).  The file access is defined for reading, writing and executing
a file.  This means it can be written as a binary number with three
digits.  A binary with three digits has values from 0 to 7 which means
it can also be written as a octal number.  777 would mean to allow
everyone everything (all three bits set for each group); if you want to
know more search for a manpage for the chmod command chmod(1) (that
means search for chmod in section 1 of the manpages).

> 3) I assume nothing will go wrong if I create a directory using
> the default mode argument for mkdir. Is this correct? I am going

Since you use WinME the mode has no effect.

> 4) What is the preferred syntax in postings, etc., for referring
> to functions that require arguments? "mkdir()" seems misleading in
> suggesting that it can be called with zero arguments,
> "mkdir(path)" seems too verbose.

If prefer mkdir().  That's the way functions are written in many
postings (assuming languages where you call functions like that).

Please do *not* send copies of replies to me.
I read the list

More information about the Tutor mailing list