Python Distilled (Addison-Wesley)

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

Python Distilled is an attempt to present Python in "short form" so that you can get to grips with it without worrying too much about the finer detail. 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 be made to seem as if it does. Indeed it is part of Python's success that at first it appears to be like these classic languages - its true nature only becomes clear when you dig a little deeper.

Banner

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

Chapter 1 is a lightning overview of Python from variables to objects. It doesn't go deep into anything - 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 was any other language and doesn't mention the important fact that a function is an object. There is a later chapter dedicated to functions so this isn't unreasonable.

Chapter 2 introduces data and does it as if Python's data structures were like those in Java, or any other object-oriented language. You learn about sets, dictionaries and so on and something about iterables and sequences, but there's no real emphasis on the way Python makes use of mixins to create classes with the characteristics of the standard data types. In Python any class can be an iterable, not just lists, and this has nothing much to do with inheritance.

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

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

 

 

Chapter 5 is a big chapter on functions, which is all right and proper as 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 it does give you the basics, but it fails to emphasize that generators are just another way to create an iterable. This doesn't matter if all you are interested in is using generators as coroutines, say, but it does if you are thinking of implementing an iterable either as a generator or using __next__. The way iterators developed from generators is briefly mentioned in a final section at the end of the chapter as a history lesson.

Chapter 7 revisits class and here we learn about how to write a class definition, but not exactly how the class works, how methods are created and how inheritance works. We do find out some deeper things later on, but it isn't until the closing sections of the chapter that we discover that a class is an object and learn about metaclass. Getting a clear idea of what is going on with class and instance is difficult.

From here the book deals with topics slightly away from the main language. Chapter 8 describes modules and packages. Chapter 9 explains file handling and Chapter 10 explores the standard library.

Conclusion

If you read this book very carefully you will notice that Python is different and has features that other languages don't have that could be useful to you. But in the main the book presents Python as if it was like Java or C++ and only then gets around to pointing out that how things actually work. For example, not emphasizing that a class is an object and how instances of the class make use of this object means that you can't really understand what is going on. This might not matter as long as you don't try and do anything out of the ordinary, but as soon as you move off from the well-beaten path, either intentionally or because you have an error to debug, then making sense of it is harder. I don't think this book brings out the unity of the overall approach Python brings to programming. It is mostly all there in the book somewhere, but you have to go looking for it. This book would be suitable for a beginner looking to improve their Python without moving too far outside of their comfort zone.

For more recommendations of Python books see see Books for Pythonistas and Python Books For Beginners in our Programmer's Bookshelf section.

To keep up with our coverage of books for programmers, follow @bookwatchiprog on Twitter or subscribe to I Programmer's Books RSS feed for each day's new addition to Book Watch and for new reviews.

Banner


Effective Python, 2nd Ed

Author: Brett Slatkin
Publisher: Addison-Wesley Professional
Pages: 480
ISBN: 978-0134853987
Print: 0134853989
Kindle: B07ZG18BH3
Audience: Python developers
Rating: 5
Reviewer: Mike James
Better Python - sounds like a fun read.



Deep Learning with JavaScript

Authors: Shanqing Cai, Stan Bileschi and Eric Nielsen
Publisher: Manning
Date: February 2020
Pages: 560
ISBN: 978-1617296178
Print: 1617296171
Audience: JavaScript Programmers
Rating: 5
Reviewer: Mike James
JavaScript doesn't seen a natural for AI but...


More Reviews

Last Updated ( Saturday, 19 March 2022 )