## Decoratordefdecorator_function(original_function:callable):defwrapper_function():print("Something is happening before the original function is called.")original_function()print("Something is happening after the original function is called.")returnwrapper_function@decorator_functiondefdisplay():print("Display function executed")display()
Something is happening before the original function is called.
Display function executed
Something is happening after the original function is called.
## Decorator with argumentsdefrepeat(num_times:int):defdecorator_repeat(original_function:callable):defwrapper_function(*args,**kwargs):for_inrange(num_times):original_function(*args,**kwargs)returnwrapper_functionreturndecorator_repeat@repeat(num_times=3)defgreet(name:str):print(f"Hello, {name}!")greet("Alice")