The Book: Second Edition

What This Book Covered

Effective Python: Second Edition Book Cover

You are reading about a previous, old version of this book. The third edition of this book (released in November, 2024) is focused exclusively on Python 3, up to and including version 3.13.

Most of the original items from the second edition have been revised and included in the third edition, but many have undergone substantial updates. For some items my advice has completely changed due best practices evolving as Python has matured.

If you’re still using an older version of Python 3 (such as 3.8 or earlier), the second edition of the book (released in November 2019) might still be useful to you.

Buy the Second Edition Book

Translations are available in 日本語, Deutsche, Polszczyzna, Hrvatski, 简体中文, 繁体中文, 한국어

History about the Second Edition

Item 10: Prevent Repetition with Assignment Expressions

Sun 02 February 2020

An assignment expression—also known as the walrus operator—is a new syntax introduced in Python 3.8 to solve a long-standing problem with the language that can cause code duplication. Whereas normal assignment statements are written a = b and pronounced “a equals b”, these assignments are written a := b and pronounced “a walrus b” (because := looks like a pair of eyeballs and tusks). Continue reading »

Item 51: Prefer Class Decorators Over Metaclasses for Composable Class Extensions

Wed 18 December 2019

Although metaclasses allow you to customize class creation in multiple ways (see Item 48: “Validate Subclasses with __init_subclass__” and Item 49: “Register Class Existence with __init_subclass__”), they still fall short of handling every situation that may arise. Continue reading »

Digital Versions of the 2nd Edition are Now Available

Wed 06 November 2019

You can immediately read the second edition of Effective Python as a DRM-free eBook, on Kindle, on Google Play, and on O’Reilly Online Learning.

Item 74: Consider memoryview and bytearray for Zero-Copy Interactions with bytes

Tue 22 October 2019

Though Python isn’t able to parallelize CPU-bound computation without extra effort (see Item 64: “Consider concurrent.futures for True Parallelism”), it is able to support high-throughput, parallel I/O in a variety of ways (see Item 53: “Use Threads for Blocking I/O, Avoid for Parallelism” and Item 60: “Achieve Highly Concurrent I/O with Coroutines” for details). That said, it’s surprisingly easy to use these I/O tools the wrong way and reach the conclusion that the language is too slow for even I/O-bound workloads. Continue reading »

Preorder the Second Edition

Mon 21 October 2019

Effective Python: Second Edition is now available for preorder. Follow this link to buy your copy in advance. It will ship in mid-November (2019) once the book has finished printing and is stocked in the warehouse. Digital editions will become available when the physical book ships or sooner.