LernerPython

Decorators

Confused about what decorators are, how they work, and how to use them?

What you should know

Course Content

Course length

2.5 hours

Number of lessons

1

Training materials

Jupyter notebook

Coding exercises

5

LEARN MORE

Decorators are one of Python’s most powerful tools — but they’re also confusing to many people. In this class, I’ll try to demystify them, showing you how decorators work, and how we can use them in a wide variety of cases. You’ll come away finally “getting” decorators, from the simplest to the most complex.

This is a recording of a webinar I gave in September 2024. It includes exercises, as well as many demos.

  • Why do we want decorators?
  • What does the @ syntax really mean (and do)?
  • How do we write a decorator?
  • How do we write a decorator that takes an argument?
  • What are some examples of how to use a decorator?
  • How can we use decorators to check and modify function arguments?
  • How can we use decorators to check and modify function return values?

As with all courses on LernerPython.com, this class is taught by Reuven Lerner.