fluttersmith/py-snippetsGitHub ↗
About

What “still pass” means.

Snippet sites go stale quietly. A result written in a comment looks the same whether or not it is still true. Here, every example is a doctest: the >>> line is run, and its output has to match what the page shows, character for character.

How it is checked

  • Each of the 40 functions lives in a real module, src/pysnippets/<package>/<module>.py. Its docstring holds the examples you see on the page, 133 in all.
  • CI runs pytest --doctest-modules on Python 3.11, 3.12, 3.13, 3.14. A page whose examples fail on any of them doesn't ship.
  • The code is type-checked with mypy --strict and linted with ruff, and the proofs on thestdlib cheat sheet (22 rows) and the JS idioms page (31 rows) run as doctests too.
  • The code and examples on each page are rebuilt from the module by snip sync, and CI fails if they differ, so the page and the tested file can't drift apart.
  • The ✓ next to an example means it passed on Python 3.11–3.14. The Run in your browser button runs the same doctests on Python3.14 through Pyodide, and turns them red if you break something.

Where the material comes from

Most snippets are adapted from 30-seconds-of-python by the 30 seconds of code contributors, used underCC BY 4.0. Each adapted page names its originals and says what changed. Many were rewritten: typed, made to handle empty input, or replaced by a standard library call. ATTRIBUTION.md accounts for all 160originals.

py-snippets is an independent project by Ahmed Hamdy. It is not affiliated with or endorsed by 30 seconds of code, and uses none of its names, logos or images as branding.

License

The project is MIT licensed. Adapted material stays under CC BY 4.0. The source, the tests and the site are onGitHub.