Skip to content

Instantly share code, notes, and snippets.

@lene
Last active January 30, 2018 14:37
Show Gist options
  • Save lene/d94517502993de04fde5 to your computer and use it in GitHub Desktop.
Save lene/d94517502993de04fde5 to your computer and use it in GitHub Desktop.
Python decorators (free function)
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