Change language

Effective Python. Second Edition


Effective Python. Second Edition Brett Slatkin

Effective Python: 90 Specific Ways to Write Better Python The Python programming language has unique strengths and charms that can be hard to grasp. Many programmers familiar with other languages often approach Python from a limited mindset instead of embracing its full expressivity. Some programmers go too far in the other direction, overusing Python features that can cause big prob- lems later.

This second edition of the Effective Python book will help you master a really "pythonic" approach to programming, harnesses python's full power to write exceptionally well performing code. Using the concise scenerio driven style pioneered in scott meyers' best selling effective c++, brett slatkin brings together 90 python best practices, tips, tricks, and shortcuts, and explain them with realistic code examples, so that you can embrace python with confidence.

Drawing on years of expertise developing Python infrastructure at Google, John Slatkin reveals little-known quirks and idiosyncrasies that powerfully impact code behavior. You'll learn the best ways to accomplish common tasks so you can write better code that's easier to understand, maintain and improve. In addition, this new edition substantially updates all items from the original edition to reflect current best practices.

Effective Python 2nd edition PDF

Each chapter in Effective Python: Second Edition contains a broader but related set of items, grouped into three parts. Feel free to jump back and forth between any two parts, and follow your interest. Part 1 covers topics such as what to do, what not to do, and how to strike the right mix. Part 2 covers topics such as how to organize code, how to structure data, and how to design APIs. Part 3 covers topics such as how you should test your code, how to debug your code, and how to improve your code. Items include advice on writing better Python programs, and references to each other so that you can fill in the gaps as needed.

“I have been recommending this book enthusiastically since the first edition appeared in 2015. This new edition, updated and expanded for Python 3, is a treasure trove of practical Python programming wisdom that can benefit pro- grammers of all experience levels.”
Wes McKinney, Creator of Python Pandas project, Director of Ursa Labs

“If you’re coming from another language, this is your definitive guide to taking full advantage of the unique features Python has to offer. I’ve been working with Python for nearly twenty years and I still learned a bunch of useful tricks, espe- cially around newer features introduced by Python 3. Effective Python is crammed with actionable advice, and really helps define what our community means when they talk about Pythonic code.”
Simon Willison, Co-creator of Django

“I’ve been programming in Python for years and thought I knew it pretty well. Thanks to this treasure trove of tips and techniques, I’ve discovered many ways to improve my Python code to make it faster (e.g., using bisect to search sorted lists), easier to read (e.g., enforcing keyword-only arguments), less prone to error (e.g., unpacking with starred expressions), and more Pythonic (e.g., using zip to iterate over lists in parallel). Plus, the second edition is a great way to quickly get up to speed on Python 3 features, such as the walrus operator, f-strings, and the typing module.”
— Pamela Fox, Creator of Khan Academy programming courses

“Now that Python 3 has finally become the standard version of Python, it’s already gone through eight minor releases and a lot of new features have been added throughout. Brett Slatkin returns with a second edition of Effective Python with a huge new list of Python idioms and straightforward recommendations, catching up with everything that’s introduced in version 3 all the way through 3.8 that we’ll all want to use as we finally leave Python 2 behind. Early sections lay out an enormous list of tips regarding new Python 3 syntaxes and concepts like string and byte objects, f-strings, assignment expressions (and their special nickname you might not know), and catch-all unpacking of tuples. Later sec- tions take on bigger subjects, all of which are packed with things I either didn’t know or which I’m always trying to teach to others, including ‘Metaclasses and Attributes’ (good advice includes ‘Prefer Class Decorators over Metaclasses’ and also introduces a new magic method ‘__init_subclass__()’ I wasn’t familiar with), ‘Concurrency’ (favorite advice: ‘Use Threads for Blocking I/O, but not Parallel- ism,’ but it also covers asyncio and coroutines correctly) and ‘Robustness and Performance’ (advice given: ‘Profile before Optimizing’). It’s a joy to go through each section as everything I read is terrific best practice information smartly stated, and I’m considering quoting from this book in the future as it has such great advice all throughout. This is the definite winner for the ‘if you only read one Python book this year...’ contest.
— Mike Bayer, Creator of SQLAlchemy

Effective Python second edition reviews

Review by Michael E Sweeney

The chapter about concurrence is somewhat confusing as the asynchronous and co-routines examples overlap, and I spent time sorting through hundreds of line of code on the github page guessing which functions, class etc. pertain to each example (s). When you finally sorted it out, he said "But what if the situations were more complicated?"

Review by Carl

What an awesome book! That teaches you some really cool Code, in examples that are Easy Follow & To the Point. Hands Down My Favorite Python Book.

Review by Darrell

I started programming in C, C++) and java around 1995. My job has also recently shifted to more python. Python wasn't difficult to pick up, almost felt like cheating writing code, but I was writing python like I would write C/C++. Looking at others' code a lot of their coding choices didn't make sense. This book does a great deal of explaining a lot of python best practices and quirks.


See also

Learn programming in R: courses


Best Python online courses for 2022


Best laptop for Fortnite


Best laptop for Excel