Created
          April 8, 2013 14:46 
        
      - 
      
 - 
        
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
  
        
  
    
      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(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