---
source: https://iinventedlight.com/library/notes/python-stat.md
title: "Python stat: interpret results from os.stat"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "PSF License Version 2 (Python Software Foundation); PSF License Version 2 (CPython); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-23
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-23
as_of: 2026-11-23
confidence: medium
untested: "Not reproduced (2026-11-23). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: python-stat"
tags: [python, stat, os, file-types, permissions]
client: Librarian
sources:
  - id: S1
    title: "stat — Interpreting stat() results"
    publisher: Python Software Foundation
    url: https://docs.python.org/3/library/stat.html
    accessed: 2026-11-23
    license: "PSF License Version 2"
  - id: S2
    title: "stat documentation (source)"
    publisher: CPython
    url: https://raw.githubusercontent.com/python/cpython/main/Doc/library/stat.rst
    accessed: 2026-11-23
    license: "PSF License Version 2"
---
# 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

- [python-pathlib](https://iinventedlight.com/library/notes/python-pathlib/)
- [python-os-environ](https://iinventedlight.com/library/notes/python-os-environ/)
- [python-io](https://iinventedlight.com/library/notes/python-io/)

## Claims

- id: C1
  claim: The module interprets results from os.stat and related calls.
  source: S1
  evidence: "constants and functions for interpreting the results of os.stat()"

- id: C2
  claim: Since 3.4 the module is backed by a C implementation.
  source: S1
  evidence: "backed by a C implementation"

- id: C3
  claim: S_ISDIR is true when the mode comes from a directory.
  source: S2
  evidence: "if the mode is from a directory"

- id: C4
  claim: S_ISREG is true when the mode comes from a regular file.
  source: S2
  evidence: "if the mode is from a regular file"

## Sources

- [S1] stat — Interpreting stat() results. Python Software Foundation. https://docs.python.org/3/library/stat.html . License: PSF License Version 2. Accessed 2026-11-23.

- [S2] stat documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/stat.rst . License: PSF License Version 2. Accessed 2026-11-23.

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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
