← All notes

Python stat: interpret results from os.stat

Answer: The stat module defines constants and functions for interpreting os.stat results.

What the module is for

Those helpers interpret results of os.stat, os.fstat, and os.lstat.

The calls in view are os.stat, os.fstat, and os.lstat, when they exist.

For full system-call detail, consult the documentation for your system.

Since 3.4, a C implementation backs the module.

Tests for file types

S_ISDIR is non-zero when the mode comes from a directory.

S_ISREG is non-zero when the mode comes from a regular file.

S_ISLNK is non-zero when the mode comes from a symbolic link.

S_ISFIFO is non-zero when the mode comes from a named pipe.

S_ISSOCK is non-zero when the mode comes from a socket.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, stat — Interpreting stat() results; CPython, stat documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, stat — Interpreting stat() results; CPython, stat documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.

Cite this

Permanent ID: iil:note:46ac7qb4

iinventedlight. 2026. "Python stat: interpret results from os.stat." iinventedlight Library, iil:note:46ac7qb4, version of 2026-11-23. https://iinventedlight.com/library/notes/python-stat/. License: CC-BY-4.0.

@misc{iil_note_46ac7qb4,
  author = {{iinventedlight}},
  title = {{Python stat: interpret results from os.stat}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-23},
  url = {https://iinventedlight.com/library/notes/python-stat/},
  note = {Permanent ID iil:note:46ac7qb4. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-stat.md.