This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: document that os.chmod accepts an octal digit mode
Type: enhancement Stage: needs patch
Components: Documentation Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: docs@python Nosy List: clutchski, docs@python, ezio.melotti, georg.brandl, loewis, terry.reedy
Priority: normal Keywords: easy, patch

Created on 2009-12-07 15:54 by clutchski, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
msg96060 - (view) Author: clutchski (clutchski) Date: 2009-12-07 15:54
It would be helpful to explicitly document that os.chmod accepts octal
digit modes e.g. os.chmod(path, 0755). This is much more user friendly
than saying you must OR bit constants kept in a completely different module.

It could be argued that this change would be make the abstraction leaky,
since the values of the stat.S_I* constants could change, but in
practice, this seems unlikely.
msg96075 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-12-07 21:13
I think you misunderstand what's happening. It's not that os.chmod
accepts octal digits, but Python:

py> 04732
2522

So the support for octal numbers isn't something that chmod deserves
credit for.
msg96081 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2009-12-07 22:48
If using octal digits instead of the stat.S_I constants is acceptable,
I'd be +1 to add a note to the documentation (something like "mode could
be a number (possibly expressed in octal form, such as 0755), one of the
following values (as defined in the stat module), or a bitwise ORed
combinations of them:").
msg113185 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-08-07 17:11
(3.1.2)
15.1.5. Files and Directories
os.chmode entry: I recommend changing the first sentence
"Change the mode of path to the numeric mode."
to
"Change the mode of path to the integer mode (such as 0x755)."

For 2.7, delete the 'x'.

This should make it clear to Unix users that they can use the usual octal designations.
msg113235 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2010-08-08 05:37
I guess you mean 0o755.
I think it would be better to mention explicitly octal literals, since they are not so common and, especially in 2.x, 0755 might be confused with a "normal" decimal number.
msg118807 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-10-15 17:20
We now have the S_IXXX constants documented explicitly, so I don't think this change is needed.
History
Date User Action Args
2022-04-11 14:56:55adminsetgithub: 51699
2010-10-15 17:20:21georg.brandlsetstatus: open -> closed
resolution: works for me
messages: + msg118807
2010-08-08 05:37:55ezio.melottisetmessages: + msg113235
2010-08-07 17:11:24terry.reedysetversions: - Python 2.6
nosy: + terry.reedy, docs@python

messages: + msg113185

assignee: georg.brandl -> docs@python
keywords: + patch, easy
2009-12-07 22:49:00ezio.melottisetpriority: normal

type: enhancement
versions: + Python 2.6, Python 3.1, Python 2.7, Python 3.2
nosy: + ezio.melotti

messages: + msg96081
stage: needs patch
2009-12-07 21:13:52loewissetnosy: + loewis
messages: + msg96075
2009-12-07 15:54:18clutchskicreate