Start reading Guide to: Learning Python Decorators on the free Kindle Reading App or on your Kindle in under a minute. Don't have a Kindle? Get your Kindle here.

Deliver to your Kindle or other device

Enter a promotion code
or gift card

Try it free

Sample the beginning of this book for free

Deliver to your Kindle or other device

Sorry, this item is not available in
Image not available for
Image not available

Guide to: Learning Python Decorators [Kindle Edition]

Matt Harrison
4.5 out of 5 stars  See all reviews (25 customer reviews)

Print List Price: $8.97
Kindle Price: $4.99
You Save: $3.98 (44%)

Free Kindle Reading App Anybody can read Kindle books—even without a Kindle device—with the FREE Kindle app for smartphones, tablets and computers.

To get the free app, enter your email address or mobile phone number.


Amazon Price New from Used from
Kindle Edition $4.99  
Paperback $8.97  
Shop the New Digital Design Bookstore
Check out the Digital Design Bookstore, a new hub for photographers, art directors, illustrators, web developers, and other creative individuals to find highly rated and highly relevant career resources. Shop books on web development and graphic design, or check out blog posts by authors and thought-leaders in the design industry. Shop now

Book Description

Do you want to take your Python to the next level?
Python is easy to learn. You can learn the basics in a day and be
productive with it. But there are more advanced constructs that you
will eventually run across if you spend enough time with it. Don't be confused by these. Learn them, embrace them, and improve your code and others.
Decorators are pretty common in modern Python. While not strictly necessary, they can reduce code size while enabling control of function input, invocation and output. They also enable separation of responsibility and DRY. Many explanations of decorators are brief and leave the reader somewhat confused. This book is an attempt to remedy that. It is based off of popular tutorials given at PyCon and Python user groups. Without fail, attendees mention that "decorators now make sense". Not only do they understand decorators, but they can write them as well.
The guide covers:
  • Functions
  • Closures
  • *args
  • **kwargs
  • Decorating with functions
  • Decorating with classes
  • Alternate decorating methods

Write Python code like the masters
These constructs, while not necessary per se, allow you to be more succinct,
re-use code, and think about code in a different way. You will learn:
  • How the constructs work
  • When to use them
  • Real life examples from the standard library
Understand other's code
This book covers many of these intermediate constructs that are available in Python. The book covers both Python 2 and 3. Topics include:
  • In's and out's of functions
  • Closures
  • Decorators
  • Real world examples of their use
Based on popular tutorials and sessions 
I have taught material similar to these constructs at popular tutorials at conferences such as PyCon, OSCON and Strata (and other
conferences). This book is based on my experience teaching and using
Python for many years. I hope you learn something while in the course
of your reading. Maybe it will help you in your next task, code
review, or job interview.
Up Your Advanced Python Skills
It is assumed that the reader has some knowledge of Python. You will walk away knowing the the in's and out's of closures and decorators, when to use them, and how to use them.

Editorial Reviews


Succinct, focused
This inexpensive ebook is a little gem. Matt gives tight, crystal clear explanations that I haven't found anywhere else.
- J. Adams
Cleaned up some ugly with closures today, after reading @__mharrison__'s decorators ebook.
- @MattJDarling

About the Author

Matt Harrison Matt Harrison has over 11 years Python experience across the domains of search, build management and testing, business intelligence and storage.
He has presented and taught tutorials at conferences such as SCALE, PyCON and OSCON as well as local user conferences. The structure and content of this book is based off of first hand experience teaching Python to many individuals.
He blogs at and occasionally tweets useful Python related information at @__mharrison__.

Product Details

  • File Size: 411 KB
  • Print Length: 45 pages
  • Simultaneous Device Usage: Unlimited
  • Sold by: Amazon Digital Services, Inc.
  • Language: English
  • Text-to-Speech: Enabled
  • X-Ray:
  • Word Wise: Not Enabled
  • Lending: Enabled
  • Amazon Best Sellers Rank: #224,882 Paid in Kindle Store (See Top 100 Paid in Kindle Store)
  •  Would you like to give feedback on images?

Customer Reviews

4.5 out of 5 stars
4.5 out of 5 stars
Share your thoughts with other customers
Most Helpful Customer Reviews
18 of 18 people found the following review helpful
5.0 out of 5 stars Secret Decoder Ring for Advanced Python Beginners February 6, 2012
Format:Kindle Edition|Verified Purchase
Once past "hello, world!" most beginners go through a long period of monkey-see-monkey-do learning to cobble together a collection of phrases that seem to work, although you're never exactly sure why. Eventually you run up against problems that you can't find a good example for and you have to do the hard work of understanding exactly what it is that you have asked your code to do. This is the beginning of the real learning.

One of the terms that floats around is the mysterious "decorator" that never seems urgent enough to look into, although they turn out to be quite useful. If you have been meaning get around to looking into this, the Guide to Learning Python Decorators is the place to start. But that's actually not the compelling reason for most Python newcomers to pick up this book.

A common source of beginner confusion is the "scope" of variables in functions: "I've written this function and it takes some values as input and derives a result through multiple steps. I can get the final result, but not all the intermediate variables that I've set. What gives?" This and similar questions arise from confusion as to when names are available within a function definition and when they are available to other functions and statements. It's sort of like trying to understand a language without knowing the difference between the present tense ("I am") and the past tense ("I was").

This book will clear up your confusions about functions even before you start to read about decoration at all. In addition to getting straight about scope, you'll finally get clarity about the difference between arguments and parameters, positional parameters, named parameters, etc.
Read more ›
Comment | 
Was this review helpful to you?
6 of 6 people found the following review helpful
5.0 out of 5 stars Level-up your python skills February 7, 2012
By Amjith
Format:Kindle Edition
This is a concise guide that covers all the necessary background in order to understand decorators.

Although many python programmers use decorators in their code, very few know how to write a decorator. Writing a decorator is considered an advanced skill and this book does an excellent job of demystifying it.

The book has dedicated sections to cover nested functions, variable function parameters, the * operator (*args, **kwargs) and closures, which are all advanced concepts that lead up to decorators.

This books serves as a stand-alone manual to python decorators. I'd highly recommend it for beginners and experts who are trying to level-up their python chops.
Comment | 
Was this review helpful to you?
6 of 6 people found the following review helpful
3.0 out of 5 stars Nice introduction, no advanced material February 20, 2013
Format:Kindle Edition|Verified Purchase
A clear and concise book. The author clearly explains the issue, bottom up: python functions, arguments, parameters, closures and finally decorators. The english is clear, so it's easy to understand the concept.
However, for a price of a full book, you could expect some advanced material: more about multiple decorators (which are only reminded in one page at the end), exceptions, detailed examples of common usage, class decorators etc.
Comment | 
Was this review helpful to you?
4 of 4 people found the following review helpful
Format:Kindle Edition|Verified Purchase
Recently, in a post titled "Python decorators" on the PythonConquersTheUniverse blog, I described what I think is wrong about most introductions to decorators, and I sketched out what I think is a better way to structure an introduction to decorators. In that post I wrote this:

There is an old saying to the effect that "Every stick has two ends, one by which it may be picked up, and one by which it may not." I believe that most explanations of decorators fail because they pick up the stick by the wrong end.

What I like about Matt Harrison's e-book "Guide to: Learning Python Decorators" is that it is structured in the way that I think an introduction to decorators should be structured. It picks up the stick by the proper end.

The first two-thirds of the Guide hardly talk about decorators at all. Instead, Matt begins with a thorough discussion of how Python functions work. By the time the discussion gets to decorators, we have been given a strong understanding of the internal mechanics of functions. And since most decorators are functions, at that point it is easy for Matt to explain the internal mechanics of decorators.

Which is just as it should be.

So I am happy to rate "Guide to: Learning Python Decorators" as HIGHLY RECOMMENDED.
Comment | 
Was this review helpful to you?
4 of 4 people found the following review helpful
2.0 out of 5 stars Not really much about the decorators. July 2, 2013
Format:Kindle Edition|Verified Purchase
The book isn't really about decorators.Well, it gives a very nice introduction to functions in Python. I also admit that it clearly explains the concept of closures.

But then we directly jump into the chapter about decorators. It mentions a few contexts in which decorators might be handy. The author explains how to construct decorators. And then... the book is over. It is neither a thorough study how to use the concept, nor a handful of hints...

There are many code examples in the book. Unfortunately, some are clearly wrong. It appears that the author didn't test these examples before putting them into the text.
Comment | 
Was this review helpful to you?
2 of 2 people found the following review helpful
5.0 out of 5 stars Very good March 14, 2013
Format:Kindle Edition|Verified Purchase
If you have never looked at or written python decorators before, this is a good book to go through the background of how and why they work, and a few examples of them in action.

It is a well written guide, however it did seem like just as you were getting to what would be the good detailed examples or advanced use cases the book just ended.

Edit: After having this book for a few months it has become very useful as the goto reference anytime I have to use decorators. For how much use I have gotten out of this guide it is definitely worth it.
Was this review helpful to you?
Most Recent Customer Reviews
4.0 out of 5 stars Simple and comprehensive explanation of python decorators
For a while, I just couldn't wrap my head around decorators and other related concepts (i.e "closures"). Read more
Published 7 days ago by itsmemattchung
4.0 out of 5 stars Four Stars
Very well written and easy to understand.
Published 3 months ago by Ron Reidy
4.0 out of 5 stars Great Decorator Explanation
This book did a great job of covering decorators.

Starts off like it should making sure you understand how functions works, and then moves to function based... Read more
Published 7 months ago by Garry Polley
4.0 out of 5 stars Discover the power Python Decorators and more ...
Overall the book served it's intended purpose to teach the reader about Python Decorators. Some knowledge of Python is assumed and I would recommend reading an introductory text... Read more
Published 9 months ago by Versalytics
5.0 out of 5 stars Five Stars
It is definitely one of the best books i have seen for learning decorators.
Published 11 months ago by Gokul
5.0 out of 5 stars Short and to the point. I finally understand this
I finally understand decorators in python and how to use them. This book makes the subject easy to understand :)
Published 13 months ago by Amazon Customer
5.0 out of 5 stars Excellent Book for Beginners
I'm a beginner Python developer and this book was easy to understand because it went over concepts in a good order. Read more
Published 13 months ago by Mely
5.0 out of 5 stars Easy to understand and contains best practices
I've gotten by just making decorators work but Matt's book helped me up my game and write them better. Thanks Matt!
Published 17 months ago by Paul Hildebrandt
4.0 out of 5 stars Consider Matt's larger book
Consider instead "Treading on Python Volume 2: Intermediate Python" which contains this booklet, along with two of Matt's other booklets.
Published 18 months ago by G. Wideman
4.0 out of 5 stars Technical, concise, simple
I am not a programmer and just learned python for fun. I found this book as a good way to learn a little more in simple language and with simple examples. Read more
Published 19 months ago by Pablo Balerio
Search Customer Reviews

More About the Author

Matt Harrison has over 10 years Python experience across the domains of search, build management and testing, business intelligence and storage.

He has presented and taught tutorials at conferences such as SCALE, PyCON and OSCON as well as local user groups. In addition he has been a private tutor teaching programming to teenagers as well as retired folk. The structure of his books are based off of his first hand experience teaching Python to many individuals.


There are no discussions about this product yet.
Be the first to discuss this product with the community.
Start a new discussion
First post:
Prompts for sign-in

Look for Similar Items by Category