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

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -