So, what exactly is a decorator? A decorator is a function that takes another function (the decorated function) as an argument and returns a new function. This new function usually extends or modifies the behavior of the original function. Decorators allow you to add functionality to functions or classes in a clean and reusable way without directly altering their source code. They essentially “wrap” the original function, adding extra behavior before or after its execution.