#Multiple decorators can be chained in Python.
#A function can be decorated multiple times with different (or same) decorators.
#We simply place the decorators above the desired function.
def star(func):
def inner(*args, **kwargs):
print("*" * 30)
func(*args, **kwargs)
print("*" * 30)
return inner
def percent(func):
def inner(*args, **kwargs):
print("%" * 30)
func(*args, **kwargs)
print("%" * 30)
return inner
@star
@percent
def printer(msg):
print(msg)
printer("Hello")
#The order in which we chain decorators matter.Example below shows the difference.
@percent
@star
def printer(msg):
print(msg)
printer("Hello")