Created
June 15, 2019 20:40
-
-
Save Linus-Albertus/3d5080b2c0b1a43865a23ab7fd92e949 to your computer and use it in GitHub Desktop.
[python decorator] An example of a Python decorator #python #decorator
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
def decorator(inner_function): | |
def wrapper(*args, **kwargs): | |
# New wrapper stuff | |
inner_function(*args, **kwargs) | |
# New wrapper stuff | |
return inner_function(*args, **kwargs) | |
return wrapper | |
@decorator | |
def decorated_function(): | |
pass | |
decorated_function() # returns the decorated_function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment