Skip to content

Instantly share code, notes, and snippets.

@junfenglx
Created November 9, 2013 16:23
Show Gist options
  • Save junfenglx/7387058 to your computer and use it in GitHub Desktop.
Save junfenglx/7387058 to your computer and use it in GitHub Desktop.
decorators run
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