Skip to content

Instantly share code, notes, and snippets.

@AeroNotix
Created February 8, 2012 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AeroNotix/1769913 to your computer and use it in GitHub Desktop.
Save AeroNotix/1769913 to your computer and use it in GitHub Desktop.
def generic_wrapper(f):
print 'entering wrapper function'
def inner_function():
print f()
print 'leaving wrapper'
return inner_function
@generic_wrapper # @ is syntactic sugar for wrapper(function)
def some_function():
return 'inside wrapped function'
some_function()
>>>entering wrapper function
>>>inside wrapped function
>>>leaving wrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment