Books

9 short, example-driven guides to one Python idea at a time.

Foundations

>>>

Python from Zero

Install to your first real script

Install Python and get to a real, working script: values and types, variables, decisions, loops, lists and dictionaries, functions, modules, files, and reading an error when something breaks. One short path, standard library only, every example run when the book was built.

Python Data Structures in Depth

Lists, tuples, sets, and dicts, and when to use each

The four containers every Python program is built from, covered properly: lists, tuples, sets, and dicts, comprehensions, and the collections module tools built on top of them. By the end you know which structure actually fits a job, not just which one happens to work.

.py

Object-Oriented Python

Classes, dunder methods, and dataclasses

A focused, example-driven guide to classes in Python: __init__ and self, the dunder methods that make a class behave like a built-in type, class methods, inheritance versus composition, properties, and dataclasses. Standard library only, and every example was run when the book was built. By the end you can read a class-based codebase and design your own small class hierarchy without guessing.

The Python Standard Library

The modules worth knowing before you reach for pip

The standard library modules that come up once you're past the basics: itertools, functools, datetime in depth, contextlib, argparse, subprocess, and logging. By the end you can build a small real command-line tool using nothing but what Python already ships with.

Intermediate

.py

Python File Handling

Reading, writing, and organizing files

A short, example-driven guide to working with files in Python: opening them safely, handling text and encodings, using pathlib for paths, and reading and writing CSV and JSON. Nothing here needs a package you have to install, and every example was run when the book was built. By the end you can get data in and out of a file without looking it up.

.py

Decorators and Closures

How they work, and how to write your own

Closures, `*args`/`**kwargs`, a decorator written from scratch, functools.wraps, decorators that take arguments, class-based decorators, and the functools toolkit (lru_cache, cached_property, singledispatch). By the end you can write your own decorators with confidence and read decorator-heavy code without losing the thread.

.py

Iterators and Generators

Lazy evaluation and pipelines that don't choke on memory

The iterator protocol, generator functions and their quirks, generator expressions, yield from, and a practical tour of itertools (chain, islice, groupby, takewhile, accumulate, and more). By the end you can write your own iterators and generators, chain them into a lazy pipeline that processes a file too large to hold in memory, and read itertools recipes without guessing what they do.

.py

Type Hints in Python

Catch bugs before you run the code

Annotating functions and variables, Optional and union types, typed collections, type aliases, typing a class, Callable, reading a mypy error, TypedDict, Protocol, and a first look at generics. By the end you can annotate a real module, run mypy against it, and know when a hint is worth adding and when it is not.

.py

Testing Python with pytest

From your first assert to a suite that stays green

Plain assert and pytest's failure output, organizing tests, fixtures and conftest.py, parametrize, marks and test selection, testing files and errors, monkeypatch and unittest.mock, coverage, and a short TDD loop. By the end you can add a real test suite to an untested project and keep it green as the code changes.