Book review – Python Tricks: The Book, by Dan Bader

Book review – Python Tricks: The Book, by Dan Bader

This is an interesting book about Python, but not the usual handbook or cookbook style. If you already know the basics and want to discover new details about this programming language, or if you want to check if you really have a solid grasp on it, this book will give you some insightful, bite-size, tips and tricks.

Yes, we all know that pythonic code should not try to be “clever”, like those long do-it-all-at-once one-liners that you may have found anywhere else. The Python community values simple code that is readable by humans. That principle has even deserved a spot on the Zen of Python:

Simple is better than complex.
Complex is better that complicated.
Readability counts.

But the tricks that Dan Bader presents on this book have a different purpose. The author takes some small tidbit and explains how it is special, why it returns some unexpected value, or how it can be used to improve your code. Dan Bader explains everything in a well paced way that makes it simpler to understand.

Not an introductory tutorial book for beginners, but a good intermediate reading to help you step up your game. In case you read the book and end up discovering that you already knew all (which is very unlikely) then you should probably be reading something more advanced (makes sense, doesn’t it?). You will have an opportunity to learn or check your knowledge about topics like string formatting, lambdas, decorators, *args and **kwargs, data structures, pythonic loops, different ways to update dictionaries, and many other simple but important tidbits.

The author made a huge (and, in my opinion, successful) effort to present these slightly advanced “tricks” in a way that is both easy to understand and that allows to explore some important aspects of the Python language that may sometimes pass unnoticed. It may contribute to a better understanding of how Python works.

On the other hand, as Mariatta Wijaya, a Python core developer, states in her foreword to this book, “mastering Python programming isn’t just about grasping the theoretical aspects of the language”, and as she explains, “it’s just as much about understanding and adopting the conventions and best practices used by its community”. And that’s another important focus of the author.

As a nice bonus, the author offers a pack of 12 Python tutorial videos (around 2 hours of content) to complement your reading.

This book won’t replace reading the documentation for the Python language and for the Python Standard Library, but it’s specially indicated for those moments you want something light to read, but still get to learn interesting and useful stuff. Anyway, as with any other learning material, to make the most of this book, make sure you get near a REPL and experiment with the examples given. And maybe use some of the tips in one of your projects. There’s no better way to consolidate your learning.

Get the book:

Disclosure Notice: For this review, I bought myself a copy of the book, paying as a regular costumer. I do not personally know the author, and did not receive any other compensation. The link to the author’s website is provided as a reference only, I am not making any profit from it.