Created
May 21, 2020 20:14
-
-
Save meganlkm/86174dfdbe3ea3ecff0ddb42aee6484c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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