Created
December 15, 2014 20:24
-
-
Save stnbu/d7a8965792c4c2cbe45d to your computer and use it in GitHub Desktop.
Trivial python decorator examples. Because I always forget.
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(orig_func): | |
"""Trivial python decorator | |
""" | |
def wrapper_func(*a, **k): | |
return orig_func(*a, **k) | |
return wrapper_func | |
def decorator_wrapper(arg): | |
"""Decorator with arg(s). Do something conditional/interesting with "arg" | |
""" | |
def decorator(orig_func): | |
def wrapper_func(*a, **k): | |
return orig_func(*a, **k) | |
return wrapper_func | |
return decorator |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment