Cover of Learning Python by Mark Lutz, published by O'Reilly Media, showing abstract Python language reference imagery

Pages

1269

Published

2025

Python ✨ New

Learning Python

A thorough reference to Python language fundamentals, from syntax and data types to classes and advanced tools

Work through Python's core language from first principles to advanced features, so you can write code that is correct, readable, and maintainable.

Learning Python by Mark Lutz is the definitive reference for anyone who wants to understand Python from the ground up. At 1,269 pages, it goes far beyond crash courses: covering types, statements, functions, modules, classes, exceptions, and advanced tools with the depth needed to write production-quality code. Whether you are new to programming or moving to Python from another language, this book gives you the mental models to reason about code, not just copy it.

About this book

Most Python tutorials teach you enough syntax to get something running. This book teaches you enough to understand why it works, and what to do when it does not. Mark Lutz has spent decades teaching Python, and Learning Python reflects that accumulated precision: every concept is built carefully on the one before it, with examples designed to expose the edges of the language rather than hide them.

You will start with Python's execution model and move systematically through its built-in types, control flow, and function system. From there the book covers modules and packages, object-oriented programming with classes and inheritance, exception handling, and the decorator and metaclass features that underpin most major frameworks. Each section includes exercises and quizzes to confirm understanding before you move on.

The book is unapologetically thorough. If you want a 50-page introduction to Python, this is not it. If you want to finish a book and genuinely understand what Python is doing when it runs your code, this is exactly it. The depth here pays dividends when you move on to any specialised domain: web development, data science, automation, or systems scripting.

  • Full coverage of Python 3 syntax, semantics, and standard idioms
  • Built-in types explored in depth: numbers, strings, lists, dicts, sets, and more
  • Function internals: scopes, closures, generators, and comprehensions
  • The class model explained from first principles, including multiple inheritance and operator overloading
  • Decorators and metaclasses without hand-waving
  • Practical guidance on writing modules, packages, and maintainable code at scale

At 1,269 pages this is a reference you return to as your skills grow. Chapters that felt dense on first read become reference material once you are working on real projects. Many working Python developers keep a copy on the desk precisely because the index and depth reward repeated consultation.

Published by O'Reilly Media, the book meets the editorial standard readers expect for precision and accuracy. If you are serious about Python as a tool, this is the foundation text.

🎯 What you'll learn

  • Explain precisely how Python executes code, from source file to bytecode to interpreter
  • Use every major built-in type correctly and understand the performance tradeoffs between them
  • Write functions that handle scope, closures, and generators without surprising side effects
  • Model real problems with classes, inheritance, and operator overloading in idiomatic Python
  • Apply decorators and metaclasses to solve cross-cutting concerns without framework magic
  • Organise code into modules and packages that other developers can navigate and extend
  • Handle exceptions in a way that makes failures predictable and debuggable
  • Read unfamiliar Python code confidently by understanding the language rules behind it

👤 Who is this book for?

  • Developers new to Python who want thorough grounding rather than a quick-start tutorial
  • Programmers coming from another language who need to understand Python's specific execution model and idioms
  • Students working through a university or bootcamp curriculum who need a reliable reference alongside their course
  • Working developers who learned Python informally and want to fill gaps in their understanding of classes, scopes, or the object model
  • Technical leads who need a definitive reference to settle language questions on their team

Table of contents

  1. 01

    Getting Started with Python

    You set up a working Python environment and run your first scripts. The chapter explains CPython's execution model so you understand what happens between writing code and seeing output.

  2. 02

    Types and Operations

    You work through Python's core built-in types: numbers, strings, lists, tuples, dictionaries, and sets. You learn how Python's dynamic type system works and why it matters for correctness.

  3. 03

    Statements and Syntax

    You cover the full set of Python statements, including assignments, conditionals, loops, and comprehensions. The chapter shows how Python's indentation-based syntax enforces structure.

  4. 04

    Functions and Functional Tools

    You build a deep understanding of Python functions: how scopes work, how closures capture state, how generators produce values lazily, and how lambda and map-style tools fit the language.

  5. 05

    Modules and Packages

    You learn how Python's import system works, how to structure code into reusable modules and packages, and how to avoid the namespace collisions that trip up larger projects.

  6. 06

    Classes and Object-Oriented Programming

    You build classes from scratch and work through inheritance, method resolution order, and operator overloading. The chapter explains Python's object model precisely, not by analogy.

  7. 07

    Exceptions and Error Handling

    You learn to raise, catch, and design exceptions that make failures explicit and recoverable. The chapter covers the full exception hierarchy and context managers.

  8. 08

    Decorators and Metaclasses

    You implement decorators that wrap functions and classes, then explore metaclasses as the mechanism behind class creation. The chapter demystifies tools that most frameworks rely on heavily.

  9. 09

    Advanced Topics and Python Internals

    You examine string encoding, managed attributes, descriptors, and other advanced mechanisms. The chapter prepares you to read and contribute to code that uses Python's more powerful features.

Frequently asked questions

Do I need prior programming experience to read this book?

Some familiarity with basic programming concepts is helpful. Readers who are completely new to programming can follow along, but the book moves at a deliberate pace rather than a beginner-hand-holding one. Prior experience with any scripting or programming language makes it easier.

Which version of Python does this edition cover?

This edition covers Python 3. Legacy Python 2 differences are noted where they are significant for readers working with existing codebases.

Is this book practical or mostly theoretical?

It is primarily a language reference, not a project-based tutorial. You will write a great deal of code in exercises and examples, but the goal is thorough understanding of the language rather than shipping a specific application.

Is this the right book if I already know Python basics?

Yes. Many readers who already know enough Python to get things done use this book to understand why things work the way they do. The sections on scopes, the class model, decorators, and metaclasses are valuable well beyond beginner level.

How does this compare to shorter introductory Python books?

Shorter books trade depth for speed. This book covers the same starting material and then continues far further into the language. If your goal is a solid mental model of Python rather than getting something running quickly, the extra pages earn their place.

Does the book include exercises or self-assessment questions?

Yes. Each part of the book includes quizzes and exercises so you can verify your understanding before moving on to the next topic.

You might also like

📬 Weekly Newsletter

Stay ahead of the curve

Get the best programming tutorials, data analytics tips, and tool reviews delivered to your inbox every week.

No spam. Unsubscribe anytime.