Created
June 26, 2013 19:04
-
-
Save davidevans/5870445 to your computer and use it in GitHub Desktop.
delayed decorator
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
class X(): | |
def inherited_func(self, func): | |
raise NotImplemented | |
def x_decorator(func): | |
def handler(self, *args,**kwargs): | |
print "In X handler" | |
self.inherited_func(func)(*args,**kwargs) | |
return handler | |
@x_decorator | |
def test(self): | |
print "In Test" | |
pass | |
class Y(X): | |
def inherited_func(self, func): | |
def handler(*args,**kwargs): | |
print "In Y handler" | |
return func(self,*args,**kwargs) | |
return handler |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment