Skip to content

Instantly share code, notes, and snippets.

@thiagoh
Created April 11, 2016 14:36
Show Gist options
  • Save thiagoh/03dceb4b03fb426376c7b17835fe5a39 to your computer and use it in GitHub Desktop.
Save thiagoh/03dceb4b03fb426376c7b17835fe5a39 to your computer and use it in GitHub Desktop.
wrapped functions: how it works
# https://docs.python.org/2/library/functools.html#functools.update_wrapper
from functools import wraps
def wrapped_func1(func):
def __inner_func():
return func()
return __inner_func
def wrapped_func2(func):
@wraps(func)
def __inner_func():
return func()
return __inner_func
@wrapped_func1
def my_function1():
pass
@wrapped_func2
def my_function2():
pass
print my_function1.__name__
print my_function2.__name__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment