About
How this site is made
One concept per page
Python By Example teaches Python through small literate programs. Each page holds one concept. Prose sits beside the source it explains, and each source fragment is followed by the output it produced. Links point at the official Python 3.13 documentation instead of restating it. 7 journeys arrange the same examples into longer arcs, each section with named learner outcomes.
Every page runs
The complete program at the bottom of each example is editable. Run sends it to an isolated Cloudflare Dynamic Worker with outbound network disabled and a one-second CPU budget. The output panel shows the real stdout of the code you ran, and the measured execution time below it.
Output is verified, not promised
Expected output is authored in each example's Markdown source and rendered beside the corresponding fragment. The build executes every supported teaching cell and complete program, then fails if captured stdout differs from that authored expectation. Cells the sandbox cannot execute are labelled as standard Python instead of pretending to run.
The figures
The small diagrams are composed from a locked drawing grammar: one palette, fixed stroke weights, a short list of shapes, and no escape hatch for raw SVG. Geometry tests check every figure for clipping and collisions before it ships. Some pages have no figure on purpose; each omission carries a recorded reason.
The quality gates
A written rubric scores every example, with a target of 9.0 and a hard minimum of 8.5. A page below target must name the work that remains; Hello World carries the only standing waiver, because first programs are traditionally tiny. Separate checks cover confusable pairs (iterator vs iterable, is vs ==), documented footguns, journey outcomes, and the links between examples.
The design language
Every page draws from the tokens below, and this section reads them from the same stylesheet it documents. In dark mode the warm palette inverts; --figure-paper stays light, so figures sit on a paper chip instead of being recoloured, and the terminal tokens keep the runner's output chip dark in both schemes.
Color
--accent--accent-text--accent-action--accent-hover--accent-soft--text--muted--page--surface--surface-2--surface-3--hairline--hairline-soft--header-veil--header-veil-0--header-veil-solid--figure-paper--terminal-bg--terminal-ink
Spacing
--space-1--space-2--space-3--space-4--space-5--space-6
Type
Names bind to objects; objects carry the type.
The rail
Source
value = 21 * 2
print(f"value = {value}")Output
value = 42The block above is not a screenshot. It is the same markup every walkthrough cell uses: monospace source on the accent rail, output under a hairline, and a copy button added when JavaScript is available.
Lineage and stack
The format follows Go by Example's example-per-page teaching and Rust By Example's expectation that examples run. Literate programming supplied the premise that prose and source should explain each other; marimo's source/output adjacency shaped the cells. The site runs on Cloudflare Python Workers with FastAPI; Shiki highlights read-only code and CodeMirror powers the editor. The source is public under the MIT license at github.com/adewale/pythonbyexample.