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

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -