Created
August 28, 2018 09:03
-
-
Save elena-roff/10eb6237c654d5520658b0428cf143de to your computer and use it in GitHub Desktop.
Decorator template
This file contains hidden or 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
# source: https://realpython.com/primer-on-python-decorators/ | |
# This formula is a good boilerplate template for building more complex decorators. | |
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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment