Skip to content

Instantly share code, notes, and snippets.

@stibi
Created May 7, 2012 21:07
Show Gist options
  • Save stibi/2630438 to your computer and use it in GitHub Desktop.
Save stibi/2630438 to your computer and use it in GitHub Desktop.
magical decorator
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