On this page
  1. os.stat
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

os.stat

Prev: os.scandir | Up: os | Next: os.stat_result
Rel: os.abort, os.access, os.chdir, os.chmod
Ref: docs.python.org — os.stat
Tags: #public #python3 #stdlib #os


Import

import os
from os import stat

Signature & Overview

os.stat(path, *, dir_fd=None, follow_symlinks=True)

Perform a stat system call on the given path.

Usage

import os
from pathlib import Path
import tempfile

with tempfile.TemporaryDirectory() as tmp:
    p = Path(tmp) / "info.txt"
    p.write_text("12345", encoding="utf-8")
    st = os.stat(p)
    assert st.st_size == 5

Gotchas

REPL Inspect

from os import stat
help(stat)

Linked from

Related notes