Python Mastery

Welcome

This book takes you from zero programming experience to advanced Python. It distills three sources into one continuous read:

  • Part 0 — Foundations. Drawn from a from-scratch beginner’s guide. Mental models, primitives, control flow, collections, functions, errors, files, classes, modules, the standard library, and the practices that make a script a real program. If you have never written Python before, start here.

  • Parts I–V. Drawn from Luciano Ramalho’s Fluent Python (2e, O’Reilly Media 2022) — the deepest treatment of the language available. The data model, sequences, dicts and sets, unicode, dataclasses, first-class functions, decorators, descriptors, metaclasses, async I/O. If you already know Python and want to understand why it feels the way it does, you can start here.

  • Throughout. David Beazley’s Python Distilled (Addison-Wesley 2022) is cited as a secondary reference — operational details, deployment, and the broader standard library — wherever its treatment complements the deep-dive chapters.

The goal is a single reading order in which each chapter builds on the last. The Foundations chapters give a first pass at decorators, generators, dataclasses, and async. The advanced parts then deconstruct them — showing how the data model, protocols, and special methods make those features work.

Every code block in this book is executed during the build. The output you read is the output the code produced.

TipHow to read this book

If you’re new to Python, read the parts in order: FoundationsData StructuresFunctionsClassesControl FlowMetaprogramming.

If you already write Python comfortably, you can skip Foundations and start with 13  The Python Data Model. The chapters in Parts I–V are largely self-contained and cross-reference each other where they overlap.

If you want a single chapter on a topic, the table of contents lets you jump in directly. Each chapter ends with cross-references to the chapters that take its topic further.

The single thread running through every chapter is the data model: the protocols and special methods that built-in syntax delegates to. Once you’ve seen this thread, the rest of the language stops feeling like a collection of features and starts feeling like one consistent system.

About this book

Found a typo, a confusing passage, or a code block that won’t run? Open an issue or a pull request — every chapter has an “Edit this page” link in the right sidebar that takes you straight to its source.