/filesnake/helpers/experiments.py
Python | 25 lines | 17 code | 5 blank | 3 comment | 1 complexity | ac923065ce7da1852eeeea46a2bbe0d2 MD5 | raw file
- from decorator import decorator
- @decorator
- def extends(f, self , *a, **kw):
- '''
- This decorator automatically calls the method of the superclass
- '''
- fname = f.__name__
- getattr(super(type(self),self),fname)(*a,**kw)
- return f(self,*a,**kw)
-
- def test():
- class B(object):
- def __init__(self, hello):
- print "hello from b"
-
- class A(B):
- @extends
- def __init__(self, hello):
- print "Hello"
- A("Hello")
- if __name__ == '__main__':
- test()