python multiple decorators

Solutions on MaxInterview for python multiple decorators by the best coders in the world

showing results for - "python multiple decorators"
Massimo
15 Jan 2021
1"""
2Just stack operators on top of each other. You can do this all you like.
3They'll act in the same order you stack them.
4"""
5
6def decorator1(func):
7    def inner():
8        print("I'm decorator 1")
9        func()
10    return inner
11  
12def decorator2(func):
13    def inner():
14        print("I'm decorator 2")
15        func()
16    return inner
17  
18def decorator3(func):
19    def inner():
20        print("I'm decorator 3")
21        func()
22    return inner
23  
24@decorator1
25@decorator3
26@decorator2
27def func():
28    print("I'm the original function")
29  
30func()