Answers for "python multiple decorators"

0

python multiple decorators

"""
Just stack operators on top of each other. You can do this all you like.
They'll act in the same order you stack them.
"""

def decorator1(func):
    def inner():
        print("I'm decorator 1")
        func()
    return inner
  
def decorator2(func):
    def inner():
        print("I'm decorator 2")
        func()
    return inner
  
def decorator3(func):
    def inner():
        print("I'm decorator 3")
        func()
    return inner
  
@decorator1
@decorator3
@decorator2
def func():
    print("I'm the original function")
  
func()
Posted by: Guest on August-08-2021

Python Answers by Framework

Browse Popular Code Answers by Language