0
class Base(object):
    def __init__(self):
        print ("Base")

class childA(Base):
    def __init__(self):
        print ('Child A')
        Base.__init__(self)

class childB(Base,childA):
    def __init__(self):
        print ('Child B')
        super(childB, self).__init__()


b=childB()

Inheritance would go as childB, Base, childA, Base and after applying MRO, it should become childB,childA,Base. But its throwing MRO error. why?

Husun
  • 29
  • 1
  • 7

1 Answers1

0

childB is attempting to inherit from Base twice, once through childA and once directly. Fix by removing the multiple inheritance on childB.

class Base(object):
    def __init__(self):
        print ("Base")

class childA(Base):
    def __init__(self):
        print ('Child A')
        Base.__init__(self)

class childB(childA):
    def __init__(self):
        print ('Child B')
        super(childB, self).__init__()

b=childB()
Easton Bornemeier
  • 1,918
  • 8
  • 22