File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -3140,6 +3140,23 @@ features:
31403140 .. attribute :: st_mode
31413141
31423142 File mode: file type and file mode bits (permissions).
3143+
3144+ .. note ::
3145+
3146+ ``st_mode `` is an **int ** bitmask that combines the file type and the
3147+ permission bits. If you expect POSIX-style values like ``755 `` or ``644 ``,
3148+ render the value in octal and/or mask out only the permission bits. For example:
3149+
3150+ .. code-block :: pycon
3151+
3152+ >>> import os, stat
3153+ >>> m = os.stat("somefile").st_mode
3154+ >>> oct(m) # includes the file-type bits (e.g. 0o100...)
3155+ '0o100755'
3156+ >>> oct(stat.S_IMODE(m)) # permissions only
3157+ '0o755'
3158+ >>> stat.filemode(m) # human-readable form
3159+ '-rwxr-xr-x'
31433160
31443161 .. attribute :: st_ino
31453162
You can’t perform that action at this time.
0 commit comments