Skip to content

Instantly share code, notes, and snippets.

@vipul-sharma20
Last active March 26, 2016 19:47
Show Gist options
  • Select an option

  • Save vipul-sharma20/b21515e873001c91ee62 to your computer and use it in GitHub Desktop.

Select an option

Save vipul-sharma20/b21515e873001c91ee62 to your computer and use it in GitHub Desktop.
# borrowed this example from http://thecodeship.com/patterns/guide-to-python-function-decorators/
def get_text(name):
return "lorem ipsum, {0} dolor sit amet".format(name)
def p_decorate(func):
def func_wrapper(name):
return "<p>{0}</p>".format(func(name))
return func_wrapper
my_get_text = p_decorate(get_text)
print my_get_text("Vipul")
# Output:
# <p>lorem ipsum, Vipul dolor sit amet</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment