Simple Decorators Example in Python
def my_decorator(func): def wrapper(): print("Step - 1") func() print("Step - 3") return wrapper @my_decorator def start_steps(): print("Step - 2") start_steps()
Output
Step - 1 Step - 2 Step - 3
def my_decorator(func): def wrapper(): print("Step - 1") func() print("Step - 3") return wrapper @my_decorator def start_steps(): print("Step - 2") start_steps()
Step - 1 Step - 2 Step - 3