Skip to content

Instantly share code, notes, and snippets.

@gregorykremler
Created October 31, 2014 21:49
Show Gist options
  • Save gregorykremler/0972dcff8e861cc4fd87 to your computer and use it in GitHub Desktop.
Save gregorykremler/0972dcff8e861cc4fd87 to your computer and use it in GitHub Desktop.
decorator example
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() ## returns <b><i>hello world</i></b>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment