Wed 2 May 2012
I bought Matt Harrison’s book, Guide To: Learning Python Decorators this week to see if I could finally understand what the big deal was about decorators. I’ve decided to try reviewing this book using Doug Hellman’s method of doing a Quick Review and then a more formal in depth review for those of you hardy enough to want to read more.
- Why I picked it up: Because I wanted to learn about decorators and I also wanted to see how this book compared with Harrison’s other books.
- Why I finished it: Simply put, the book was short and I could read it in between other tasks I was doing. Also, some of Harrison’s insights about functions were really interesting.
- I’d give it to: An intermediate to advanced Python developer that needed to do meta-programming or had to understand functions and function generators
The only place I can find to purchase this book is on Amazon for their Kindle, even from the author’s website. So I’m guessing mobi is the only format supported at this time unless you can finagle something else out of the author.
This eBook doesn’t really have chapters. They seem more like named sections to me.
Functions - All kinds of information about functions and how they work
Function Parameters – This chapter talks about how *args, **kwargs and what they’re good for. It also talks about “splatting” or flattening using the “*” operator.
Closures – A quick and dirty chapter on what Closures are and how they lead up to Decorators.
Decorators – The last portion of the book is about decorators, of course. It covers simple decorators, decorator templates, parameterized decorators, multiple decorators and a class decorator of sorts.
I found the book to be pretty straight forward and interesting. Most of the time, the author writes in a candid, approachable way. It sounds like a beginner’s book, but I think it would be more appropriate for an experienced beginner to intermediate programmer as Mr. Harrison gets into some heady topics when he gets into function generators, closures and decorators. I saw a typo here and there, but overall, I thought the prose was quite good. Occasionally there were bits that were rather repetitious and there were times where the note sections were stacked up. The problem with stacked notes is that they are kind of mini side pieces and can interrupt the flow of the text.
If you don’t understand the nuts and bolts of functions and you want to finally learn those new fangled decorators, I would recommend this book as a good way to get a handle on these topics.