DEV Community

prasanna Kumar
prasanna Kumar

Posted on

Decorators

A decorator is a function that modifies the behavior of another function.

Syntax:

def decorator_function(original_function):
    def wrapper_function():
        # Code to execute before the original function
        original_function()
        # Code to execute after the original function
    return wrapper_function

@decorator_function
def display():
    print("Display function executed.")
display()

Enter fullscreen mode Exit fullscreen mode

Top comments (0)