Last active
March 26, 2016 19:47
-
-
Save vipul-sharma20/b21515e873001c91ee62 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # 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