Created
May 7, 2012 21:07
-
-
Save stibi/2630438 to your computer and use it in GitHub Desktop.
magical decorator
This file contains 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
class Test(object): | |
def decorator(bar=True): | |
def magic(foo): | |
def magic2(self): | |
if bar: | |
print "Hey, bar is here" | |
print "start magic" | |
foo(self) | |
self.try_me() | |
print "end magic" | |
return magic2 | |
return magic | |
@decorator(bar=False) | |
def bar(self) : | |
print "ook!" | |
def try_me(self): | |
print "Hi there!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment