Decorators / Functools Wraps
Opened this issue · 0 comments
s2t2 commented
References:
- https://www.python.org/dev/peps/pep-0318/
- https://docs.python.org/3/library/functools.html#functools.wraps
from functools import wraps
def my_decorator(f):
@wraps(f)
def wrapper(*args, **kwds):
print('Calling decorated function')
return f(*args, **kwds)
return wrapper
@my_decorator
def example():
"""Docstring"""
print('Called example function')
example()