Last active
January 30, 2018 14:37
-
-
Save lene/d94517502993de04fde5 to your computer and use it in GitHub Desktop.
Python decorators (free function)
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
from functools import wraps | |
def decorator(func): | |
@wraps(func) | |
def func_wrapper(*args, **kwargs): | |
return do_stuff_to_func(func(*args, **kwargs)) | |
return func_wrapper | |
@decorator | |
def example(): | |
return 1 # returns do_stuff_to_func(1) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment