Test files › Source code › sample.py

Sample Python file (sample)

A Python module with type hints, a dataclass, a generator, f-strings and a triple-quoted docstring.

↓ Download sample.py
Filenamesample.py
FormatPython
Size693 bytes (693 bytes)
MIME typetext/x-python; charset=utf-8
SHA-256383d1b4d296abfbb898653535afd74123a5bde452b7df12b0e9ef72730b42391
What this file catchesHighlighters and extractors that mishandle triple-quoted strings, and any tool that counts braces to find blocks. Python has none, so indentation is the only structure, which is what makes the mixed-indentation file below a genuine failure and not a style question.

Handle it in code

Each snippet below was run against this exact file with Python 3.14.4 and Node 24.15.0 when this page was built, and the output shown is what it printed.

Python

The standard tabnanny module finds indentation that mixes tabs and spaces ambiguously, the kind that looks right in one editor and raises TabError in Python 3.

import contextlib
import io
import tabnanny

report = io.StringIO()
with contextlib.redirect_stdout(report):
    tabnanny.check("sample.py")
print(report.getvalue().strip() or "indentation is consistent")

Run against this file, it prints: indentation is consistent

Related guides and tools

MIME typesVerify its SHA-256

Download & verify

curl -fsSL -o "sample.py" "https://files.hexaqa.com/code/sample.py"
curl -fsSL "https://files.hexaqa.com/code/sample.py" | sha256sum # expect: 383d1b4d296abfbb898653535afd74123a5bde452b7df12b0e9ef72730b42391

More source code test files

mixed-indentation.pysample.tsschema.sql

← All Source code files