Created
February 23, 2014 21:40
-
-
Save cmertayak/9177700 to your computer and use it in GitHub Desktop.
Python Decorator Example
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
| def makebold(fn): | |
| def wrapped(): | |
| return "<b>%s</b>" % fn() | |
| return wrapped | |
| def makeitalic(fn): | |
| def cover(): | |
| return "<i>%s</i>" %fn() | |
| return cover | |
| @makeitalic | |
| @makebold | |
| def hello(): | |
| return "Hello World" | |
| print hello() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment