Author: David Beazley
Publisher: Addison Wesley
Date: September 2021
Pages: 352
ISBN: 978-0134173276
Printing: 0134173279
Rating: 4
Reviewer: Alex Armstrong
Python is not a big language but it is getting bigger all the time.


Distilled Python is an attempt to present Python in a “short form” so that you can get on with it without worrying too much about the finer details. This is a useful approach, especially if you are coming from another language such as Java or C++. Python doesn’t do things the same way, but it can look like it does. Indeed, it’s part of Python’s success that at first it resembles those classic languages ​​- its true nature only becomes clear when you dig a little deeper.

The book covers Python in 10 chapters and 350 fairly small type pages. That said, it’s really only the first seven chapters that deal with the core of Python. It’s also worth saying that it only covers Python 3.6, which would be fine, except that means it doesn’t include pattern matching, which is arguably the biggest change to Python since abandonment of version 2 for the incompatible 3.

Chapter 1 is a quick overview of Python, from variables to objects. It doesn’t go into great detail – just presents the basic ideas. For example, in the section on functions, it just tells you how to define a Python function as if it were another language and doesn’t mention the important fact that a function is an object. There’s a later chapter dedicated to functions so that’s not unreasonable.

Chapter 2 presents data and does it as if Python’s data structures were like those of Java or any other object-oriented language. You’ll learn more about sets, dictionaries, etc., and something about iterables and sequences, but there’s not really a focus on how Python uses mixins to create classes with the characteristics standard data types. In Python, any class can be an iterable, not just lists, and that has nothing to do with inheritance.

Chapter 3 introduces control flow and covers ifs and while loops before moving on to exceptions and context handlers. As already mentioned, there is nothing about pattern matching.

Chapter 4 discusses objects and classes and again covers the ideas as if it were Java. No mention of a class as an object, nothing about the metaclass, nothing about how methods are created by the first binding functions. For some of these topics, we have to wait for Chapter 7.

Chapter 5 is a big chapter on functions, which is fine because Python functions are very special and very powerful. It covers all varieties of parameter types and moves on to decorators and using functions as callbacks.

Chapter 6 is about generators and gives you the basics, but it doesn’t emphasize that generators are just another way to create an iterable. It doesn’t matter if all you care about is using generators like coroutines, for example, but it does if you plan to implement an iterable either as a generator or using __next__ . How iterators evolved from generators is briefly mentioned in a final section at the end of the chapter as a history lesson.

Chapter 7 revisits the class and here we learn how to write a class definition, but not exactly how the class works, how methods are created and how inheritance works. We discover deeper things later, but it is only at the end of the chapter that we discover that a class is an object and that we learn the metaclass. It’s hard to get a clear idea of ​​what’s going on with the class and the instance.

From there, the book deals with topics slightly removed from the main language. Chapter 8 describes modules and packages. Chapter 9 explains file management and Chapter 10 explores the standard library.

Conclusion

If you read this book carefully, you’ll notice that Python is different and has features that other languages ​​don’t have that might be useful to you. But overall, the book presents Python as if it were like Java or C++ and only then does it start pointing out how things actually work. For example, not emphasizing that a class is an object and how instances of the class use that object means you can’t really figure out what’s going on. It might not matter as long as you don’t try to do something unusual, but as soon as you stray from the well-trodden path, either intentionally or because you have an error to debug, so giving it meaning is more difficult. I don’t think this book brings out the unity of the overall approach that Python brings to programming. It’s almost all there in the book somewhere, but you have to go find it. This book would suit a beginner looking to improve their Python without going too far out of their comfort zone.

For more Python book recommendations, see see Books for Pythonistas and Python books for beginners in our Programmer’s library section.

To keep up with our coverage of books for programmers, follow @bookwatchiprog on Twitter or subscribe to the I Programmer’s Books RSS feed for daily Book Watch releases and new reviews.