- Series: Effective Software Development Series
- Paperback: 256 pages
- Publisher: Addison-Wesley Professional; 1 edition (March 8, 2015)
- Language: English
- ISBN-10: 0134034287
- ISBN-13: 978-0134034287
- Product Dimensions: 7 x 0.7 x 9 inches
- Shipping Weight: 1 pounds (View shipping rates and policies)
- Average Customer Review: 4.6 out of 5 stars See all reviews (65 customer reviews)
- Amazon Best Sellers Rank: #15,024 in Books (See Top 100 in Books)
Enter your mobile number or email address below and we'll send you a link to download the free Kindle App. Then you can start reading Kindle books on your smartphone, tablet, or computer - no Kindle device required.
To get the free app, enter your mobile phone number.
Effective Python: 59 Specific Ways to Write Better Python (Effective Software Development Series) 1st Edition
Use the Amazon App to scan ISBNs and compare prices.
Frequently bought together
Customers who bought this item also bought
From the Publisher
“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 realize there’s so much more I could be doing with my Python code to make it faster (e.g., using built-in data structures), easier to read (e.g., enforcing keyword-only arguments), and much more Pythonic (e.g., using zip to iterate over lists in parallel).”
–Pamela Fox, educationeer, Khan Academy
“If I had this book when I first switched from Java to Python, it would have saved me many months of repeated code rewrites, which happened each time I realized I was doing particular things ‘non-Pythonically.’ This book collects the vast majority of basic Python ‘must-knows’ into one place, eliminating the need to stumble upon them one-by-one over the course of months or years. The scope of the book is impressive, starting with the importance of PEP8 as well as that of major Python idioms, then reaching through function, method and class design, effective standard library use, quality API design, testing, and performance measurement–this book really has it all. A fantastic introduction to what it really means to be a Python programmer for both the novice and the experienced developer.”
–Mike Bayer, creator of SQLAlchemy
“Effective Python will take your Python skills to the next level with clear guidelines for improving Python code style and function.”
–Leah Culver, developer advocate, Dropbox
“This book is an exceptionally great resource for seasoned developers in other languages who are looking to quickly pick up Python and move beyond the basic language constructs into more Pythonic code. The organization of the book is clear, concise, and easy to digest, and each item and chapter can stand on its own as a meditation on a particular topic. The book covers the breadth of language constructs in pure Python without confusing the reader with the complexities of the broader Python ecosystem. For more seasoned developers the book provides in-depth examples of language constructs they may not have previously encountered, and provides examples of less commonly used language features. It is clear that the author is exceptionally facile with Python, and he uses his professional experience to alert the reader to common subtle bugs and common failure modes. Furthermore, the book does an excellent job of pointing out subtleties between Python 2.X and Python 3.X and could serve as a refresher course as one transitions between variants of Python.”
–Katherine Scott, software lead, Tempo Automation
“This is a great book for both novice and experienced programmers. The code examples and explanations are well thought out and explained concisely and thoroughly.”
–C. Titus Brown, associate professor, UC Davis
“This is an immensely useful resource for advanced Python usage and building cleaner, more maintainable software. Anyone looking to take their Python skills to the next level would benefit from putting the book’s advice into practice.”
–Wes McKinney, creator of pandas; author of Python for Data Analysis; and software engineer at Cloudera
About the Author
Brett Slatkin is a Senior Staff Software Engineer at Google. He is the engineering lead and co-founder of Google Consumer Surveys. He formerly worked on Google App Engine's Python infrastructure. He is the co-creator of the PubSubHubbub protocol. 9 years ago he cut his teeth using Python to manage Google's enormous fleet of servers. Outside of his day job, he works on open source tools and writes about software, bicycles, and other topics on his personal website. He earned his B.S. in Computer Engineering from Columbia University in the City of New York. He lives in San Francisco.
Browse award-winning titles. See more
If you are a seller for this product, would you like to suggest updates through seller support?
Top Customer Reviews
The examples are clear. They are not some 'dry' Class X, method Y sort of examples, they tend to use examples that better illustrate the scenario; so if you at first don't get the author's explanation, you might see what's going on because of the connotations that come with sensible examples.
The formatting and layout are fairly good, especially with syntax highlighting code. There are few goofy spots where text talks about code that's displayed on the next page, so to relate one to the other you need to flip pages back'n'forth, and some tables/boxes spill over to the next page for like two lines. But that's just minor nit-picking.
My biggest 'complaint' is about what's NOT in the book. There is only a slight mention of itertools, or any functional programming concepts, that are so neatly baked into Python. There is also very slim amount of information on testing, which I would like to read more about, as it's become very commonplace. I would love to see a second edition of this book with extended sections on the aforementioned topics.
One aspect I appreciated was how the author shows a naive implementation of a common solution. This is often a solution most people would think of, and these naive solutions looked correct at first glance. The author then shows where the naive solution fails, why it fails, and a way to do it better.
I particularly liked Item 37 which discussed threads in Python. It describes the CPython implementation and the GIL (global interpreter lock) in a way I have not seen before. It was a clear description and informative.
The chapters have a good range in difficulty from easy to challenging. For example, Item 2 is a recommendation to use PEP 8 as a style guide. This chapter will be easily accessible to anyone. However, Chapter 4 about Metaclasses and Attributes was extremely challenging for me.
Each sentence is well written and packed with information. Side notes are provided when needed and these were also useful. The coloring of the book is nice, as it looks like an interactive development environment to show which keywords are highlighted. The examples provided in the Items are relevant to current programming practices.
This is hardly a fault of the language development community, which is mindful of the One Way™ principle in design discussions. Nor is it due to lack of community-established practices, which are spread around in PEPs, high-impact open source projects, mailing list advice, and the blogs of prominent community members.
As developers, we perhaps collectively tend to neglect reading code, following our communities, improving our fundamentals, and thinking about how we improve our approach to building software. And perhaps it's because these activities seem to draw away from our favorite activity: building stuff.
But, of course, the activity of writing code is just one component of building stuff. Knowledge of our tools and how to best use them helps us to build more stuff in less time, spend less time debugging and fixing our old stuff, and work more easily with others.
Effective Python is a time-efficient way to learn – or remind yourself – what the best practices are and why we use them. It’s a concise book of practical techniques to write maintainable, performant and robust code using practices widely accepted in the community.
In the style of Scott Meyer's "Effective" series, the book is split into 59 sections (referred to as "items"), each covering an important topic conducive to high-quality Python code. These items connect to a larger theme within each chapter, such as "Pythonic Thinking", "Metaclasses and Attributes", or "Concurrency and Parallelism”.
Each item introduces a common scenario in Python development, often followed by a simple way to address the problem at hand. The book frequently starts out with simplistic code that developers may be temped to use to solve a particular problem, points out issues with it, and incrementally improves the code to incorporate best practices. The alternative solution(s) proposed are often both simpler and more robust than the seemingly straightforward, but flawed, initial approach. A few sections substantiate the preferred approach with simple explanations of what Python is doing under the hood.
The broad set of topics addressed include readability ("Prefer Helper Classes Over Bookkeeping with Dictionaries and Tuples"), protecting memory ("Use tracemalloc to Understand Memory Usage and Leaks"), writing defensive code ("Know the Differences Between bytes, str, and unicode"), creating powerful classes ("Annotate Class Attributes with Metaclasses"), using parallelism ("Consider Coroutines to Run Many Functions Concurrently"), and development practices ("Profile Before Optimizing").
Unlike many books on programming languages, Effective Python leaves installation instructions and a basic language tutorial to books focused on Python beginners, and assumes that the reader has cursory knowledge of the language — or is, occasionally, willing to look something up.
To help the reader understand some of the issues in a broader context, many of the items refer to other sections for explanations of out-of-scope but related topics. The contained nature of the items makes them equally suitable for random access (skipping from one section to another) as for back-to-back reading.
This book distills the best practices spread around the ‘net. Reading it is a time-effective way to make sure you’re up to speed with writing great Python code.