Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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')
if __name__ == '__main__':
example()
# Calling decorated function
# Called example function
# print(example.__name__)
# 'example'
# print(example.__doc__)
# 'Docstring'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.