DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Start Coding With Google Cloud Workstations
  • Beyond ChatGPT, AI Reasoning 2.0: Engineering AI Models With Human-Like Reasoning
  • Why I Started Using Dependency Injection in Python
  • Reinforcement Learning for AI Agent Development: Implementing Multi-Agent Systems

Trending

  • Power BI Embedded Analytics — Part 2: Power BI Embedded Overview
  • *You* Can Shape Trend Reports: Join DZone's Software Supply Chain Security Research
  • Scalable System Design: Core Concepts for Building Reliable Software
  • Scalable, Resilient Data Orchestration: The Power of Intelligent Systems
  1. DZone
  2. Coding
  3. Languages
  4. Book Review — Effective Python, by Brett Slatkin

Book Review — Effective Python, by Brett Slatkin

An overview of Effective Python, by Brett Slatkin (principal software engineer at Google), reveals 90 specific ways to write better Python code.

By 
Victor Domingos user avatar
Victor Domingos
·
Oct. 06, 20 · Review
Likes (5)
Comment
Save
Tweet
Share
5.6K Views

Join the DZone community and get the full member experience.

Join For Free

Those among you who have already learned some Python or may even have used it in some projects will certainly have heard the expression “Pythonic Code”, which conveys a general and somewhat wide meaning of “clean code and good software development practices in the context of Python”. With Effective Python, the author presents you with nothing less than 90 practical examples on how to adopt a pythonic developer mindset and how to write better Python code.

This is the second edition of a great book that Brett Slatkin had published in 2015, and which many of you may still recall. But this new edition has lots of new content (it has grown from 59 to 90 subjects or sections, and from around 250 to more than 400 pages). It has also been updated to cover some important new features that are included in recent Python versions, up to Python 3.8, which is currently the most up-to-date stable version and will be supported for some years after 3.9 comes out.

So, even if you have read the first edition, it may be worth checking it out because, besides having been revised and updated to reflect the constantly evolving best practices, it covers some more recent topics like assignment expressions (a.k.a. the walrus operator).

Book Structure and Contents

First of all, I must say that I really enjoyed the graphical layout of the book, the font size and spacing, and especially its subtle use of color for section titles and for syntax highlighting. Those small details, in my opinion, significantly contribute to a pleasant reading experience.

book page

Effective Python is composed of 10 chapters, starting with themes like “Pythonic Thinking” and “Lists and Dictionaries”, and spreading to more advanced topics like “Concurrency and Parallelism” or “Robustness and Performance”. Each chapter aggregates 7 to 13 items, which are smaller sections (usually less than 10 pages).

Each of those sections is focused around a specific and practical recommendation, like “Item 6: Prefer Multiple Assignment Unpacking Over Indexing”, or “Item 63: Avoid Blocking the asyncio Event Loop to Maximize Responsiveness”.

You can check the full list of items at the official website of effectivepython.com.

book

Since this is an intermediate to advanced level book, you may find things you already are familiar with, especially in the first chapters. However, my experience with it is that even there you may find some precious and useful information. That’s the case, for instance, of the explanation in chapter 1 about assignment expressions, a feature that was introduced with Python 3.8, but one that many Python developers are still not very comfortable with.

book

Every programmer needs to be able to use an arsenal of data structures, starting of course with lists and dictionaries, which are both covered in chapter 2. Once again, the books starts with a somewhat fundamental topic (sequence slicing) and goes on to other less known intricacies, like “Item 17: Prefer defaultdict Over setdefault to Handle Missing Items in Internal State”.

book

Each section (or item, as they’re called in the book) includes a brief and clear explanation and some code examples that illustrate its topic. As I mentioned before, the code samples are nicely formatted with syntax highlighting and tend to be pretty short and simple, so that you can quickly understand the idea being presented.

book

Finally, each item ends up with a shortlist titled “Things to Remember”, which summarises its main ideas. I just love technical and scientific books that include nice summaries like these, because it makes a lot easier for the readers to check if they have correctly understood what they have read. But it is also very useful when we just need to select a few sections, both while skimming throw the book to find out the most interesting topics, or when we are getting back to it after some time in order to search for an answer that we know is somewhere inside the book.

book

Conclusions

This is a book that I definitely recommend to anyone who already has some basic or intermediate knowledge of Python. You can read it cover to cover, or just pick the specific topics that you’re interested in at a given time, and get back to it later when you need it. Even more experienced Python users may still benefit from some of the explanations in this book, like those on chapter 6 (“Metaclasses and Attributes”) or on chapter 7 (“Concurrency and Parallelism”).

In a world where the web is full of videos and tutorials on programming (which is great, but not always the most efficient way to learn), it is good to know that there are excellent quality books like this one being published, both on print and on digital formats, which can guide us throughout our journey towards a deeper knowledge of Python and its best programming practices.

Disclosure Notice: For this review, I received a free copy of the book from the publisher. I do not personally know the authors or the publishers, and did not receive any other compensation. The link to the publisher is provided as a reference only, I am not endorsing the company or making any profit from it.

Book Python (language)

Published at DZone with permission of Victor Domingos. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Start Coding With Google Cloud Workstations
  • Beyond ChatGPT, AI Reasoning 2.0: Engineering AI Models With Human-Like Reasoning
  • Why I Started Using Dependency Injection in Python
  • Reinforcement Learning for AI Agent Development: Implementing Multi-Agent Systems

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!