Cheat sheets
Fast references
Thirty focused cheat sheets covering the language, the standard library and the production toolchain.
Python syntaxData typesString methodsList methodsDictionary methodsSet methodsComprehensionsFunctionsScope & LEGBOOPMagic methodsIteratorsGeneratorsDecoratorsContext managersExceptionsType hintsAsyncIOThreadingMultiprocessingTesting / PytestFastAPISQLAlchemyPydanticLoggingPerformanceSecurityProject structureInterview checklistProduction checklist
Featured
Comprehensions
python
squares = [x*x for x in range(10)]
evens = [x for x in nums if x % 2 == 0]
pairs = {k: v for k, v in items}
unique = {x % 3 for x in nums}
gen = (x*x for x in range(10)) # lazy generatorDict essentials
python
d.get(key, default) # safe lookup
d.setdefault(key, []) # get-or-create
d |= other # merge (3.9+)
for k, v in d.items(): ...
from collections import Counter, defaultdictAsync basics
python
import asyncio
async def main():
async with asyncio.TaskGroup() as tg: # 3.11+
tg.create_task(work(1))
tg.create_task(work(2))
asyncio.run(main())Pytest
python
import pytest
@pytest.fixture
def client(): ...
@pytest.mark.parametrize("a,b,exp", [(1,2,3),(2,2,4)])
def test_add(a, b, exp):
assert add(a, b) == exp
def test_raises():
with pytest.raises(ValueError):
parse("nope")Tooling & versions
Version-sensitive facts live in editable metadata (not hard-coded into lessons). Last verified against upstream release pages on the dates shown.
| Package | Stable | Min | Python | Verified |
|---|---|---|---|---|
| Python (CPython)Language | 3.13.x | 3.10 | — | 2026-07-21 |
| FastAPIBackend | 0.115.x | 0.110 | >=3.8 | 2026-07-21 |
| PydanticValidation | 2.x | 2.0 | >=3.8 | 2026-07-21 |
| SQLAlchemyDatabase | 2.x | 2.0 | >=3.8 | 2026-07-21 |
| AlembicDatabase | 1.14.x | 1.12 | >=3.8 | 2026-07-21 |
| PostgreSQLDatabase | 17.x | 14 | — | 2026-07-21 |
| RedisCache/Store | 7.x | 6.2 | — | 2026-07-21 |
| pytestTesting | 8.x | 7.4 | >=3.8 | 2026-07-21 |
| RuffTooling | 0.7.x | 0.5 | >=3.7 | 2026-07-21 |
| mypyTooling | 1.13.x | 1.8 | >=3.8 | 2026-07-21 |
| uvTooling | 0.5.x | 0.4 | >=3.8 | 2026-07-21 |
| httpxHTTP | 0.28.x | 0.27 | >=3.8 | 2026-07-21 |
| Docker EngineDevOps | 27.x | 24 | — | 2026-07-21 |
| NumPyData Science | 2.x | 1.26 | >=3.10 | 2026-07-21 |
| pandasData Science | 2.x | 2.1 | >=3.9 | 2026-07-21 |
| scikit-learnMachine Learning | 1.5.x | 1.3 | >=3.9 | 2026-07-21 |
| PyTorchMachine Learning | 2.x | 2.1 | >=3.9 | 2026-07-21 |