Winner of the 2014 Jolt Award for "Best Book" "Whether you are an experienced programmer or are starting your career, Python in Practice is full of valuable advice and example to help you improve your craft by thinking about problems from different perspectives, introducing tools, and detailing techniques to create more effective solutions." -Doug Hellmann, Senior Developer, DreamHost If you're an experienced Python programmer, Python in Practice will help you improve the quality, reliability, speed, maintainability, and usability of all your Python programs. Mark Summerfield focuses on four key design patterns for coding elegance, faster processing through concurrency and compiled Python (Cython), high-level networking, and graphics. He identifies well-proven design patterns that are useful in Python, illuminates them with expert-quality code, and explains why some object-oriented design patterns are irrelevant to Python. He also explodes several counterproductive myths about Python programming-showing, for example, how Python can take full advantage of multicore hardware. All examples, including three complete case studies, have been tested with Python 3.3 (and, where possible, Python 3.2 and 3.1) and crafted to maintain compatibility with future Python 3.x versions. All code has been tested on Linux, and most code has also been tested on OS X and Windows. All code may be downloaded at www.qtrac.eu/pipbook.html. Coverage includes Leveraging Python's most effective creational, structural, and behavioral design patterns Supporting concurrency with Python's multiprocessing, threading, and concurrent.futures modules Avoiding concurrency problems using thread-safe queues and futures rather than fragile locks Simplifying networking with high-level modules, including xmlrpclib and RPyC Accelerating Python code with Cython, C-based Python modules, profiling, and other techniques Creating modern-looking GUI applications with Tkinter Leveraging today's powerful graphics hardware via the OpenGL API using pyglet and PyOpenGL
The first few chapters explain most of the Gang of Four design patterns in Python ... After patterns, the author tackles concurrency (with separate sections on CPU-bound and I/O-bound concurrency), integration with other languages, high-level networking, and writing portable GUIs. The latter topic is based on Tkinter
I’ve started reading this book right after finishing Learning Python Design Patterns, since I was mainly interested in design patterns. Aware of the fact that only one of the four parts of this title covers the subject, I quickly went through all of its three hundred and some pages. This allowed me to both explore more in depth the concepts I was interested in and, at the same time, have a couple of titles to compare. I’ve ended up with a bitter sweet taste in my mouth: the design patters coverage is not bad, not at all. But the author tries to cover way too many different topics in such a thin book, ending up providing little value.
Python in Practice is not a book for beginners. It does not aim to teach the reader how to write “Hello World� in Python. The author makes it as clear as day that this targets expert developers interested in improving their knowledge with this advanced material.
But let’s dive into the book itself! As aforementioned, this book is divided into four sections covering, in order, design patterns, improving processing speed, network programming and graphics.
Design patterns are covered in the first three chapters. While the first one was honestly painful to get through, overall this section was good: the author concisely presents creational, structural and behavioral patterns with good examples and step by step explanations. I would have liked to see more images and schemas, but I’m satisfied with the meal.
The second to fourth parts of the book were instead disappointing. Mind, I don’t mainly refer to the readability or the way the concepts are presented, but rather to the choice of the author to cover all those subjects, which are worthy a book each just to get introduced to them, in some two hundred pages.
For example, the part dedicated to improving the processing speed obviously resolves to Cython. I hardly doubt anyone can get a good grasp of the language with only those little pages. Same with graphic libraries: Tkinter deserves way more pages to get you properly started. This results in the reader getting confused and either skipping chapters or getting mad finding documentation online.
So, final thoughts� I was interested in design patters. That subject is decently covered. Still, I do prefer Learning Python Design Patterns. Talking about the other topics, I think that the intentions of the author were good, but the result was different than expected.
Suggested readings:
Learning Python Design Patterns: a title fully dedicated to design patterns. Definitely recommended.
Learning Cython Programming: since this book introduces Cython, here’s a book that definitely covers the subject as it should be. It requires some good knowledge of both Python and C.
As usual, you can find more reviews on my personal blog: Feel free to pass by and share your thoughts!
I bought this book primary for its chapters about design patterns as well as the concurrency and the networking chapters (1 to 3, 4 and 6 accordingly). The book doesn't meant to be read from start to finish, but as a reference and guide to each topic separately. I think that from the above chapters I've already read most of the content, as well as the chapter about GUI with tkinter. I have nothing to say though about the two remaining chapters (extending python and 3d graphics).
The best chapter of this book is the one about high-level concurrency. In this chapter Summerfield explain the difference between CPU-bound and I/O-bound concurrency and have a strong suggestions regarding the tools to use for concurrency with python 3. Namely, the suggestion is to use the threading, multiprocessing and concurrent.futures modules and never use locks or other lower level synchronization primitives explicitly, use queues and futures instead. The examples are good, although I found the code unnecessarily complex sometimes.
On the other hand, I found the chapters about design patterns to be much less fruitful. The author attitude is too object oriented for me where things could be done much easier using a decorator or two instead. The code examples too, are complex and non pythonic.
I'm sure that there are much better approaches to high-level networking then those described in this book. The author implement remote procedure call server and client. Simple examples can be done in a simpler manner then the suggested code and advance use cases may prefer higher level 3rd party libraries and frameworks that removes much of the boilerplate (e.g. Django + DRF for REST server + requests based client).
To summerize, the high-level concurrency chapter is really great and deserve 5 stars, but the rest of the book is ranging between 2 and 3.