python - How to invoke the super constructor? -
class a: def __init__(self): print "world" class b(a): def __init__(self): print "hello" b() hello
in other languages i've worked super constructor invoked implicitly. how 1 invoke in python? expect super(self)
doesn't work.
super()
returns parent-like object in new-style classes:
class a(object): def __init__(self): print "world" class b(a): def __init__(self): print "hello" super(b, self).__init__() b()
Comments
Post a Comment