In Python, decorators are functions that conveniently alter functions, methods or classes using a special syntax. Decorators dynamically alter the functionality without changing the source code being decorated.
In Python, decorators are functions that conveniently alter functions, methods or classes using a special syntax:
@decorator_function
def python_function():
'''a python function'''
Which is equivalent to this:
python_function = decorator_function(python_function)