Effective Python will help you master a truly “Pythonic” approach to programming, harnessing Python's full power to write exceptionally robust and well-performing code. Using the concise, scenario-driven style pioneered in Scott Meyers’ bestselling Effective C++, Brett Slatkin brings together 59 Python best practices, tips, and shortcuts, and explains them with realistic code examples.
Drawing on years of experience building Python infrastructure at Google, Slatkin uncovers little-known quirks and idioms that powerfully impact code behavior and performance. You’ll learn the best way to accomplish key tasks, so you can write code that’s easier to understand, maintain, and improve.
Key features include
• Actionable guidelines for all major areas of Python 3.x and 2.x development, with detailed explanations and examples
• Best practices for writing functions that clarify intention, promote reuse, and avoid bugs
• Coverage of how to accurately express behaviors with classes and objects
• Guidance on how to avoid pitfalls with metaclasses and dynamic attributes
• More efficient approaches to concurrency and parallelism
• Better techniques and idioms for using Python’s built-in modules
• Tools and best practices for collaborative development
• Solutions for debugging, testing, and optimization in order to improve quality and performance
This excellent little book will make you a better Python programmer in many ways. It comprises 59 different recipes of how to use Python more effectively. These range from programming in the small – such as using slicing, list comprehensions, generators, enumerate, zip – to progressively larger issues – such as exceptions, keyword arguments, custom containers – then on to trickier concepts – such as metaclasses, threads, coroutines, built-in modules – to programming in the large – such as reliable pickling, docstrings, packages, unit testing, profiling, and finding memory leaks.
Each one of the recipes explains the issue, discusses one of more solutions, with examples and discussion of tradeoffs, and concludes with a short list of the things to remember. The discussion of various tradeoffs gives great insight into the underlying issues, and the examples are well chosen and very useful.
Even if you follow only a few of the recipes, you will find they make your Python coding more effective. If you follow all 59, your code should fairly fly! Highly recommended.