Further reading¶
This handbook covers the core of what "using Python fluently" takes. To go deeper, here is a filtered list: the official documentation is the authoritative reference, a few books build a systematic understanding, and the practice sites keep your hand in.
The official documentation¶
docs.python.org is the most accurate and most current material, and its structure is worth becoming familiar with:
| Part | When to read it |
|---|---|
| the tutorial | filling gaps, as a quick pass |
| the library reference | what you look at most day to day; read a module's documentation before using it |
| the language reference | when you want a piece of syntax's exact meaning |
| the HOWTOs | deep dives on one topic, strongly recommended: the descriptor guide, the logging guide, functional programming, the sorting guide, a conceptual overview of asyncio |
| What's New | every time you upgrade |
| the data model | the authoritative account of every special method |
The PEPs worth reading:
- PEP 8: the style guide
- PEP 20: the Zen of Python (
import thisin the REPL) - PEP 257: docstring conventions
- PEP 484: where type annotations began
- PEP 636: the pattern matching tutorial
The type system's specification and best practices are collected at typing.python.org.
Books¶
| Book | Suits |
|---|---|
| Fluent Python (2nd edition), Luciano Ramalho | the first recommendation. A deep treatment of the data model, functions, objects and concurrency, pointing in exactly this handbook's direction and essential reading to go further |
| Effective Python, Brett Slatkin | best practices one item at a time, each short enough to read in a spare moment; take the newest edition |
| Robust Python, Patrick Viafore | type annotations and designing maintainable code |
| Architecture Patterns with Python, Harry Percival & Bob Gregory | domain-driven design, dependency inversion and the repository pattern in Python, which suits people writing business systems; there is a free online edition |
| High Performance Python, Micha Gorelick & Ian Ozsvald | profiling and optimization |
| Python Testing with pytest, Brian Okken | a systematic treatment of pytest |
Talks¶
All of these are on YouTube and every one is worth watching:
- Ned Batchelder, Facts and Myths about Python Names and Values: the clearest talk there is on the object model.
- Raymond Hettinger, Transforming Code into Beautiful, Idiomatic Python: dozens of examples of idiomatic form.
- Raymond Hettinger, Beyond PEP 8: what genuinely good code is.
- David Beazley, Generators: The Final Frontier and the rest of his generator series: generators taken to their limit.
- Łukasz Langa, the AsyncIO video series (the EdgeDB channel): asyncio from the beginning.
Reading source¶
Reading good code is one of the fastest ways to improve. The standard library itself is excellent material (jump to the definition in your editor and there it is):
| Module | What there is to learn |
|---|---|
collections/__init__.py |
how namedtuple, OrderedDict, Counter and ChainMap are implemented |
functools.py |
wraps, partial, lru_cache, singledispatch, cached_property |
contextlib.py |
how contextmanager and ExitStack are implemented |
dataclasses.py |
how a class decorator generates methods dynamically |
pathlib/ |
a well-designed object-oriented API |
Among third-party libraries, httpx (a clear design with parallel synchronous and asynchronous APIs), rich (heavy use of the special methods and protocols) and attrs (the dataclass's ancestor) are worth reading.
Places to practise¶
- Exercism's Python track: with mentor feedback, which suits practising "the idiomatic form" particularly well.
- LeetCode: algorithms alongside practice with
collections,heapq,bisectanditertools. - Advent of Code: December's programming puzzles, which are enjoyable and suit practising data processing and generators.
- Project Euler: mathematically inclined programming problems.
Keeping up¶
- The official Python blog and discuss.python.org: new versions and the PEP discussions.
- Real Python: high-quality tutorial articles.
- PyCoder's Weekly and Python Weekly: a weekly selection of articles and projects.
- The Talk Python To Me podcast.
Found a mistake or a better way to say it? Edit this page on GitHubReport an issue