Created
November 9, 2013 16:23
-
-
Save junfenglx/7387058 to your computer and use it in GitHub Desktop.
decorators run
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 makebold(fn): | |
def wrapped(): | |
return "<b>" + fn() + "</b>" | |
return wrapped | |
def makeitalic(fn): | |
def wrapped(): | |
return "<i>" + fn() + "</i>" | |
return wrapped | |
@makebold | |
@makeitalic | |
def hello(): | |
return "hello world" | |
print hello() | |
#output:<b><i>hello world</i></b> | |
#src:http://stackoverflow.com/a/739665 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment