Advanced Lesson 4
Python Decorators
Chapter 2: Python decorators
Chaining decorators
You can also decorate a function with multiple decorators. They will be executed in the order that they are listed.
What do you think the output for the code below will be? Verify it!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
The decorated function will be equivalent to:
1 |
|
What happens when you swap the order of decorators? Guess, and then verify! (I won’t give you the output!)
1 2 3 4 5 6 |
|