About Learning Python, 5th Edition

[Larger book cover]

Purchase pointers

[June 2013] I'm pleased to announce the release of the 5th Edition of the book Learning Python—the most comprehensive version of this classic and foundational Python language tutorial.

This new edition, designed for all Python learners in all Python domains, has been brought thoroughly up-to-date with Python 3.3 and 2.7, and expanded substantially to reflect current practice in the Python world. Like its previous editions, this book also applies to all other Python releases in common use today. Whether you're using 3.X, 2.X, or both, you'll find this new edition tailored to your current and future needs.

Among other language extensions, this edition incorporates Python 3.3's namespace packages and Windows launcher, as well as 2.7's adoption of 3.X features such as set and dictionary comprehensions. In addition, this version has grown more 2.X compatible, and has been augmented with enhanced coverage of tools such as super(), descriptors, the MRO, and metaclasses, which have grown more pervasive in today's Python code.

As always, this book is designed to be an in-depth introduction to the core Python language, and work much like a self-paced class on Python fundamentals. With quizzes, exercises, and solutions, its material embodies nearly two decades of live Python training experience and feedback from real Python learners like you. There's more on this book's content and scope in the Previews below and its main title page.

Learning Python, 5th Edition is available in print, ebook, and online forms from all the usual places, including Amazon and O'Reilly. For purchase options and links, please see the Purchase pointers page. FAQ: there are no plans for a new edition, as noted below.


More Resources



In brief, this edition's main parts reflect major language topics:

Getting Started An introduction to Python and ways to launch code
Types and Operations In-depth coverage of Python's built-in objects
Statements and Syntax Python's procedural statements' syntax and roles
Functions and Generators Functions and functional-programming tools
Modules and Packages Modules, module packages, and related concepts
Classes and OOP Comprehensive OOP coverage—from basic to advanced
Exceptions and Tools Raising and catching exceptions, context managers, tools survey
Advanced Topics Unicode, descriptors, properties, decorators, metaclasses, and more
Appendixes Usage tips, Windows launcher, Python changes, exercise solutions

For more details, check out the Preface excerpt, or the full Table of Contents in the O'Reilly sampler.

Example Programs

There are hundreds of examples in this text. Some are short code segments typed and run at the Python interactive prompt, and others are larger scripts or modules coded and run in files. Although typing code manually is an important part of the learning process, the book's larger examples can also be fetched both here and here.

Related Books

The following two books are designed to complement and augment Learning Python, forming a 3-book documentation set:

These two related books are not required reading, and some readers may opt to instead focus on specific application domains after finishing Learning Python's fundamentals coverage. For those looking for extra resources, though, they are suggested texts.

Recent Notes

(Mar-2019) Want to run the book's code on your phone?

This book mentions using Python on the Android and iOS mobile platforms in passing, but it is now entirely feasible to work though the book's examples and exercises on your smartphone. On Android, for example, the Termux app provides a full-featured Linux environment for running code in a console; the Pydroid 3 and QPython apps allow you to run Python code in GUI IDEs; and programmer-friendly keyboards may help. iOS also has multiple Python options, including Pythonista.

For more on using Python on Android, check out this site's related documents here and here; they focus on running Python tkinter GUIs on Android (also possible today), but cover general Android topics along the way. Of course, phones are not everyone's idea of coding-friendly tools, but these devices are becoming powerful enough to double as general-purpose computers, especially when paired with keyboards, mice, and styli.

(Jun-2018) More Temporary Inventory Outages

[Update: after this post, the publisher began printing 6,000 books per run, which seems to have finally addressed inventory issues well. If you find an outage today, it's likely to be very short-lived.]

This book went out of stock again at Amazon in May-June 2018, despite ongoing all-time-high demand. As this note is being written, the outage has lasted for six weeks, but the publisher has 3,500 new units on the way, and will be printing another 5,000 almost immediately. This will hopefully suffice while the logistics story is improved over the next few months, but see the Nov-2017 note below for more pointers.

(Nov-2017) Temporary Inventory Outages

Due to publisher inventory policies beyond my control, rising demand has occasionally caused the print version of this book to go out of stock at Amazon (most recently, for the entire month of November 2017, a regrettable but rare outage). If you find this book unavailable at Amazon, you may want to try another vendor (e.g., Barnes & Noble), or place a back order at Amazon when possible. Although the publisher sometimes falls behind unexpected demand, it is reprinting this book regularly, and shipping delays are not generally very long. At least that's the story for the book's English version; translations tend to be hazier still.

(Aug-2016) Paging Changes in Printing 14

The publisher migrated this edition to a new tools chain for its 14th printing, released in August 2016. No material was added or removed in this printing, but formatting differences in the new tools chain impacted this and later printings in two ways: the page count increased by roughly 40 pages (to 1640), and page number locations of specific content changed slightly. The latter of these has some consequences for errata page reports:

To address both of the last two points, any new errata reports will include page numbers for both newer and older printings. On the upside, the impact of this change is expected to be negligible, as most errata have already been caught and fixed at the 3-year point in this edition's history; thanks to all who took time to note the typos.

(Jun-2016) About Future Editions

[Update: as of 2019, this story hasn't changed from that below. As it is, this book's sales make it difficult for the publisher to keep it in stock; see the two inventory notes above.]

There are currently no plans for a new edition of this book. As of June 2016, the 5th Edition is just 3 years old. It provides in-depth coverage of language and programming fundamentals that span all Python versions—past, present, and future—and remains fully relevant to all Python programmers and applications today. Moreover, because its content has chronicled two decades of Python's history, this classic text also provides context important for understanding Python's current state.

Given the constant change of Python's development, readers should expect to supplement any learning resource with documentation on recent Python releases. For more on new editions, see this page. For more on post-publication Python changes, see the survey on this site, and Python's What's New docs.

(May-2016) About Other "Learning Python"s

Packt Publishing released a book also titled "Learning Python" in December 2015. I have nothing to do with this other book, and it is in no way associated with my book. This other book seems very different from my two-decade work, but its title is a clear infringement of a trademark owned by my publisher.

Unfortunately, my publisher opted to do nothing about the infringement, and instead confusingly sells the other book, and even promotes it instead of mine. Given the amount of time and resources spent on developing my book, this seems a bizarre business model, and makes about as much sense as Apple advertising a competitor's "iPhone." As always, please use discretion when purchasing texts—even on my own publisher's website!

[Home page] Books Code Blog Python Author Train Find ©M.Lutz