Skip to main content

stat

The stat module defines constants and helpers for interpreting the result of os.stat, os.fstat, and os.lstat.

Source-of-record: Lib/stat.py, Modules/_stat.c, stat docs.

Mode test functions

FunctionPredicate on st_mode
S_ISDIR(mode)Directory.
S_ISCHR(mode)Character device.
S_ISBLK(mode)Block device.
S_ISREG(mode)Regular file.
S_ISFIFO(mode)FIFO / named pipe.
S_ISLNK(mode)Symlink.
S_ISSOCK(mode)Socket.
S_ISDOOR(mode)Door (Solaris).
S_ISPORT(mode)Event port (Solaris).
S_ISWHT(mode)Whiteout.

Decomposition

FunctionReturns
S_IMODE(mode)Permission bits.
S_IFMT(mode)File-type bits.
filemode(mode)'drwxr-xr-x'-style string.

File-type constants

S_IFDIR, S_IFCHR, S_IFBLK, S_IFREG, S_IFIFO, S_IFLNK, S_IFSOCK, S_IFDOOR, S_IFPORT, S_IFWHT.

Permission constants

GroupConstants
UserS_IRUSR, S_IWUSR, S_IXUSR, S_IRWXU.
GroupS_IRGRP, S_IWGRP, S_IXGRP, S_IRWXG.
OtherS_IROTH, S_IWOTH, S_IXOTH, S_IRWXO.
BitsS_ISUID, S_ISGID, S_ISVTX.
CombinedS_IREAD, S_IWRITE, S_IEXEC.

Windows file attributes

FILE_ATTRIBUTE_* constants for st_file_attributes on Windows.

Gopy status

AreaState
All S_IS* predicatesComplete.
Decomposition (S_IMODE, filemode)Complete.
File-type, permission, and Windows constantsComplete.

Reference

  • CPython 3.14: stat.
  • Lib/stat.py, Modules/_stat.c.
  • module/_stat/. gopy port.