summaryrefslogtreecommitdiff
path: root/pypers/recipes/superattr.py
blob: 5228057db89e99c2a029dbe820ffbbf65c79b307 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class Super(object):
    def __init__(self, cls, meth):
        self.cls = cls
        self.meth = meth
    def __call__(self, *args, **kw):
        return getattr(super(self.cls, obj or objtype), self.meth)
    
class B(object):
    def __init__(self):
        print "B.__init__"

class C(object):
    def __init__(self):
        print "C.__init__"
        print self.__init__.super(self)

C.__dict__["__init__"].super = Super(C, "__init__")


c = C()