Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
GreenGeeks Web Hosting - Faster, Scalable & Eco-Friendly

BlueHost Web Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

getflywheel wordpress hosting


Distribute your Resume to 500+ Job Boards & Recruiters


8,101 questions

11,281 answers

573 users

How to use multiple inheritance and method resolution order (MRO) in Python

5 Answers

0 votes
class A:
    def m(self):
        print("class A: m(self)")
 
 
class B(A):
    def m(self):
        print("class B(A): m(self)")
 
 
class C(A):
    def m(self):
        print("class C(A): m(self)")
 
 
class D(B, C):
    def m(self):
        print("class D(B, C): m(self)")


do = D()
B.m(do)

 
'''
run:
 
class B(A): m(self)
 
'''

 




answered Feb 12 by avibootz
0 votes
class A:
    def m(self):
        print("class A: m(self)")
 
 
class B(A):
    def m(self):
        print("class B(A): m(self)")
 
 
class C(A):
    def m(self):
        print("class C(A): m(self)")
 
 
class D(B, C):
    def m(self):
        print("class D(B, C): m(self)")

do = D()
C.m(do)

 
'''
run:
 
class C(A): m(self)
 
'''

 




answered Feb 12 by avibootz
0 votes
class A:
    def m(self):
        print("class A: m(self)")
 
 
class B(A):
    def m(self):
        print("class B(A): m(self)")
 
 
class C(A):
    def m(self):
        print("class C(A): m(self)")
 
 
class D(B, C):
    def m(self):
        print("class D(B, C): m(self)")

do = D()
A.m(do)

 
'''
run:
 
class A: m(self)
 
'''

 




answered Feb 12 by avibootz
0 votes
class A:
    def m(self):
        print("class A: m(self)")
 
 
class B(A):
    def m(self):
        print("class B(A): m(self)")
 
 
class C(A):
    def m(self):
        print("class C(A): m(self)")
 
 
class D(B, C):
    def m(self):
        print("class D(B, C): m(self)")
        A.m(self)
        B.m(self)
        C.m(self)

do = D()
do.m()

 
'''
run:
 
class D(B, C): m(self)
class A: m(self)
class B(A): m(self)
class C(A): m(self)
 
'''

 




answered Feb 12 by avibootz
0 votes
class A:
    def m(self):
        print("class A: m(self)")
 
 
class B(A):
    def m(self):
        print("class B(A): m(self)")
        A.m(self)
 
 
class C(A):
    def m(self):
        print("class C(A): m(self)")
        A.m(self)
 
 
class D(B, C):
    def m(self):
        print("class D(B, C): m(self)")
        B.m(self)
        C.m(self)

do = D()
do.m()

 
'''
run:
 
class D(B, C): m(self)
class B(A): m(self)
class A: m(self)
class C(A): m(self)
class A: m(self)
 
'''

 




answered Feb 12 by avibootz
...