Created
November 22, 2013 05:50
-
-
Save fsword/7595435 to your computer and use it in GitHub Desktop.
python decorate example
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
#!/usr/bin/env python | |
def dec(fn): | |
def inner_fn(*args): | |
result = fn(*args) | |
print "the result is: " + result | |
return result | |
return inner_fn | |
@dec | |
def hello(): | |
print 'execute' | |
return 'hello' | |
hello() | |
def hello(): | |
print 'execute' | |
return 'hello' | |
hello() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment