Skip to main content
Loading page…
Python Mastery
Chapter 17
Lesson 2 of 3
Decorators
Contents
Notes
Tutor
Concept
Decorators Demystified
Loading activity…
Previous
1 / 8
Continue
Contents
Notes
Discussion
Tutor
30 min
8 activities
0 of 8 done
In this lesson
1
Decorators Demystified
2
functools.wraps — Preserving Identity
3
Decorators with Arguments (Decorator Factories)
4
Stacking Decorators
5
Check: Decorator Application Order
6
Practice: Write a Logging Decorator
7
Practice: Decorator with Arguments — @repeat(n)
8
Real-World Decorator Uses
Objectives
Write a decorator from scratch and apply it with the @ syntax
Preserve a decorated function's metadata using functools.wraps
Create a decorator factory (decorator with arguments)
Stack multiple decorators and predict the application order
Chapter 17 · Decorators, Closures & Context Managers
Closures & First-Class Functions
Decorators
Context Managers (with)
Previous: Closures & First-Class Functions
Next: Context Managers (with)