What is a decorator ?
A decorator in Python is any callable Python object that is used to modify a function or a class. A reference to a function “func” or a class “C” is passed to a decorator and the decorator returns a modified function or class.
Sample Program of Decorator
def decorator_function(func):
def msg():
print("Hey...")
func()
return msg
@decorator_function
def deco1():
print("This is a decorator function.")
deco1()
def deco2():
print("This is also a decorator function")
# abc = decorator_function(deco2)
# abc()