Guide to: Learning Python Decorators

Introducing Guide to: Learning Python Decorators

Guide To: Learning Python Decorators is a complete guide to the theory and implementation of decorators. Decorators are pretty common in Python. While not strictly necessary, they can reduce code size while enabling control of function input, invocation and output. 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 them, but they can write them as well.

Learn Decorators

Decorators are used all over the place in modern Python code. They are used for:

  • Caching expensive calculations
  • Retrying a function that might fail
  • Redirecting sys.stdout to capture what a function prints to it
  • Logging the amount of time spent in a function
  • Timing out a function call
  • Access control
  • More …

Buy Now. Only $15.99

Join the hundreds of others who have learned these tips from the author through conference tutorials and sessions now presented in book form.

Packed with Useful Hints and Tips

This books covers:

  • Programming paradigms in Python
  • First-class functions
  • Function scope
  • Nested functions
  • Function parameters
  • Closures
  • Free variables
  • The splat operator
  • Closures
  • Decoratoring with functions
  • Decorating with classes
  • Decorator templates
  • Parameterized decorators
  • Well-behaved decorators
  • Multiple decorators
  • Common uses for decorators

You’ll learn the best practices without wasting time searching or picking up advice here and there. I’ve collected all the gems I’ve gleaned over years of writing and teaching Python for you.

A No Nonsense Guide to Decorators in Python

Decorators explained the way they SHOULD be explained ...

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...

Which is just as it should be.

S Ferg (USA)

3 options available for purchase

  • Purchase the Book alone. This contains the best-selling book on Python decorators, explaining their theory and use. It contains a bundle with professionally formatted, DRM-free EPUB and Mobi files (compatible with Kindle, iPad, Nook and more).

Only $9.99

  • Purchase the Book and Learning Kit. In addition the the highly regarded book on Python decorators, you will receive a series of files containing assignments for learning closures and decorators. An accompanying video explains how to do the assignments. The Learning Kit also contains a PDF handout for you to print containing all of the information for creating your own decorators.

Only $15.99

  • Purchase the Group Set. This set includes the Book and Learning Kit as well as a group license for 20 of your co-workers. Not only will you be proficient in decorators, your co-worker will be as well.

Now only $29.99

Praise for the Book and Related Tutorials

Complete! All you must know about Python Decorators: theory, practice, standard decorators.
All written in a clear and direct way and very affordable price.
Nice to read in Kindle.

F. De Arruda (Brazil)

This is a very well written piece that delivers. No fluff and right to the point, Matt describes how functions and methods are constructed, then describes the value that decorators offer.


Highly recommended, even if you already know decorators, as this is a very good example of how to explain this syntax illusion to others in a way they can grasp.

J Babbington (USA)

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. The author concedes that this introductory material is something that some readers will find "pedantic," but reports that many people find it helpful. He's being too modest. The distinctions he draws are essential to moving your programming skills beyond doing a pretty good imitation to real fluency.

R Careago (USA)

#1 Book for Python Programming

Amazon Jan 2012 Python New Releases

#1 Book for Python Programming

Amazon Feb 2012 Python New Releases

“guide to python decorators is crisp, concise, clear”

kracekumar Python Programmer

“I'm fairly certain I understand how decorators work now. Thanks to @__mharrison__'s presentation. Time to try out the exercises.”

Amji R. Beginning Python Programmer

“So I have a much clearer understanding of Closures in general, and func decorators in Python. Thanks @__mharrison__ !”

Stephen M. Python Programmer

Loved @__mharrison__ talk at #scale10x on Python decorators - learned a lot!

Akkana P. Tutorial Attendee

@__mharrison__ Your #python decorator session was a top tier talk at #scale10x. Thx for presenting. Let me know when your book is available.

Sharon L. @smichelleism

Just got a great refresher on Py decorators from @__mharrison__, years after being shown the light by @RanjitJhala #SCaLE10X

Qays P. @qayshp

Understanding decorators, *args, **kwargs etc. made driving down to #SCALE10x worth it. Thankyou @__mharrison__

Ewan O. @ultrahax

Wow, @__mharrison__ is *killing* it with his Python functions and decorators talk. Lots of good info. #SCALE10x

Derek P. @dmpayton

I'm fairly new to python and your talk was *extremely* informative and interesting. I can imagine all sorts of cool use cases for decorators and am imagining even perhaps a standard library of decorators!

Jeremy K. Tutorial Attendee

About the Book

Guide to: Learning Python Decorators distills years of experience coding and teaching Python and presents it in a easily digestable form. It is full of examples to illustrate the skills needed to read and write decorators in Python. Also {“included are callouts to indicate common gotchas as well as best practices”}. Those looking to understand how decorators work and how to write them will be able to come up to speed much faster with this book than working on their own.

Guide to: Learning Python Decorators is the book I wanted when I was learning decorators in Python. I have taught Python to hundreds over the years at conferences, and user groups, and I’m combining the most pertinent and useful information for you.

Buy Now. Only $15.99

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 this book is based off of his first hand experience teaching Python to many individuals.

Matt occasionally tweets useful Python related information at __mharrison__ and Matt blogs at