Skip to content

Instantly share code, notes, and snippets.

@tarasn
Created April 8, 2013 14:46
Show Gist options
  • Save tarasn/5337328 to your computer and use it in GitHub Desktop.
Save tarasn/5337328 to your computer and use it in GitHub Desktop.
Python decarators usage example how to print <b><i>Hello</i></b> using decorators
def makebold(fn):
def wrapped(s):
return "<b>" + fn(s) + "</b>"
return wrapped
def makeitalic(fn):
def wrapped(s):
return "<i>" + fn(s) + "</i>"
return wrapped
@makebold
@makeitalic
def say(s):
return s
def main():
print say('Hello!!!')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment