1 min read 32 words Updated Sep 24, 2026 Created Sep 24, 2026
#Programming#python

Decorators can be used to inject functionality into functions and methods.

def decorator(func):
    def wrapper():
        print("Before function call")
        func()
        print("After the function call")
    return wrapper

@decorator
def say_whee():
    print("Hello world!")