Python decorators by Reuven M. Lerner

Python decorators

All about one of Python's most powerful tools

Get access for $150
Thumb decorator image

Overview

One of the most powerful and advanced techniques that Python offers is known as a "decorator." Simply put, a decorator allows you to trap functions and classes when they are defined, and again when they are run, and do .... well, whatever you want with them.

Decorators are hard for many people to understand — what they do, when we would want to use them, and then how to go about doing so. In this class, recorded from an online session in July 2017, we do a deep dive into Python decorators, covering such topics as:

  • Built-in decorators (property, staticmethod, classmethod)
  • The idea behind decorating
  • Classes as decorators
  • Functions as decorators
  • Decorating methods
  • Decorators that take arguments
  • Uses for decorators
  • Tips and tricks

Note: This is a recording from an online course that I gave.  A more expanded version of this course, re-recorded and divided into sections for offline use, will be available in the coming months.  If you purchase this course, you will get access to that one for free.

This course includes not only the video, but also solutions to the (many) exercises, and the PDFs of slides that I have prepared for this course.

What's included?

Video Icon 1 video File Icon 3 files

Contents

Video
Python decorators
4:01:07
Slide PDFs
Basic decorators
49 KB
Advanced decorators
65.5 KB
Solutions to exercises
decorators.ipynb
67.9 KB

FAQs

Do I need to be a Python expert to benefit from this course?

Decorators depend on a number of things: Treating functions and classes as objects, defining some magic methods, and understanding how parameters are passed (using *args and **kwargs).  If you are completely familiar with these, then you should be just fine learning about decorators.  If not, then I'd suggest learning about functions and classes — perhaps through some of my other books and courses!

What do you mean, this is a "live course"?

I gave this course live and online to a number of people in July 2017. The video available here is the recording of that course, including pauses during which people were working on exercises.  This course is being reworked to have even more content, but broken up into many smaller sections, without the pauses, and more appropriate for  learning in chunks from home (or work).

If you buy this course now, then you'll get the revamped version for free. 

What if I dislike the course?

If you don't think  you got value from the course, then ask for a refund, and I'll give you one.
Mid reuven headshot

Because better developers have better careers

Have a more satisfying, successful, and lucrative career, by becoming more fluent in Python, Git, and related technologies.