understanding the concept of method resolution ordering in python -


when call x=d() why c's init() not getting called b's init() getting called , d's constructor..should'nt order b,a,c,d secondly,x.f() shows error wrong argument passing ..

enter image description here

what doing wrong??

concerning f, forgot self keyword declare them methods.

for calls constructors, need use 'super' in each , every class of inheritance tree.

class a(object):     def __init__(self):         super(a, self).__init__()         print "a.__init__"      def f(self):         print "a.f"  class b(a, object):     def __init__(self):         super(b, self).__init__()         print "b.__init__"  class c(object):     def __init__(self):         super(c, self).__init__()         print "c.__init__"      def f(self):         print "c.f"  class d(b, c, object):     def __init__(self):         super(d, self).__init__()         print "d.__init__"  x = d() x.f() 

and :

c.__init__ a.__init__ b.__init__ d.__init__ a.f 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -