Created
February 8, 2012 14:22
-
-
Save AeroNotix/1769913 to your computer and use it in GitHub Desktop.
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 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