Created
March 19, 2012 17:17
-
-
Save timofurrer/2119854 to your computer and use it in GitHub Desktop.
Python simple 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
#!/usr/bin/python | |
def decorator( fn ): | |
def wrapper( ): | |
print( "Befor the function is called" ) | |
fn( ) | |
print( "After the function is called" ) | |
return wrapper | |
@decorator | |
def bar( ): | |
print "Hello World!" | |
#foo = decorator( bar ) | |
#foo( ) | |
bar( ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 11 - print("Hello World!")