You are reading about the previous, old version of this book. The second edition of this book (released in November, 2019) is focused exclusively on Python 3, up to and including version 3.8.
Most of the original items from the first edition have been revised and included in the second edition, but many have undergone substantial updates. For some items my advice has completely changed between the two editions of the book due best practices evolving as Python has matured.
If, for whatever reason, you’re still primarily using Python 2, despite its end-of-life on January 1st, 2020, the first edition of the book (released in March, 2015) may be more useful to you.
Also available in translations:
I worked with Addison-Wesley to produce a video version of the book Effective Python. You can view samples and buy the video on the publisher’s website.
It includes 5 hours of video, covering 32 items from the book in six lessons. The content is primarily me using a source code editor to write Python programs that demonstrate the items from the book.
Threads give Python programmers a way to run multiple functions seemingly at the same time. But there are three big problems with threads: Continue reading »
Printed, physical copies of the Effective Python book are now for sale! Follow this link to buy directly from the publisher (free shipping in the USA). The publisher also has ePub and PDF versions available. Follow this link to buy from Amazon. Amazon also has a Kindle edition available.
Many of Python’s built-in APIs allow you to customize behavior by passing in a function. These hooks are used by APIs to call back your code while they execute. Continue reading »
A common use of metaclasses is to automatically register types in your program. Registration is useful for doing reverse lookups, where you need to map a simple identifier back to a corresponding class. Continue reading »
Building larger and more complex programs often leads you to rely on various packages from the Python community. You’ll find yourself running
pip to install packages like
numpy, and many others.
The problem is that by default
pip installs new packages in a global location. That causes all Python programs on your system to be affected by these installed modules. In theory, this shouldn’t be an issue. If you install a package and never
import it, how could it affect your programs?
Continue reading »
When a function takes a list of objects as a parameter, it’s often important to iterate over that list multiple times. Continue reading »
The final draft of the book is done. It’s 55,000 words, 250+ pages, 8 chapters, 59 items. Reviewers spent a lot of time looking over earlier drafts to ensure that the book will be useful. Now it’s off to production to be turned into a printable layout.