Skip to content

Instantly share code, notes, and snippets.

@meganlkm
Created May 21, 2020 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meganlkm/86174dfdbe3ea3ecff0ddb42aee6484c to your computer and use it in GitHub Desktop.
Save meganlkm/86174dfdbe3ea3ecff0ddb42aee6484c to your computer and use it in GitHub Desktop.
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