Decorators in Python follow a similar pattern that you’ve learned:
import functools
def decorator(func):
@functools.wraps(func)
def wrapper_decorator(*args, **kwargs):
# Do something before
value = func(*args, **kwargs)
# Do something after
return value
return wrapper_decorator
This lesson will show you how to use the code snippet above as a template or boilerplate to write your decorators.