TypeError: Cannot create a consistent method resolution
order (MRO) for bases A, C
TypeError: Cannot create a consistent method resolution
order (MRO) for bases B, D
class A: pass
class B(A): pass
class C(A): pass
class D(B): pass
class Class_4(D,A): pass
#class Class_3(A,C): pass#TypeError: Cannot create a consistent method resolution order (MRO) for bases A, C
#class Class_2(B,D): pass#TypeError: Cannot create a consistent method resolution order (MRO) for bases A, C
class Class_1(C,D): pass
Ans is A,D
Ok guys.Here is your answer.I only typed it in VSSCODE and here it is:
https://drive.google.com/file/d/122fvfA91ZyKcsq7qlaBQXYcGH0x7e9Ja/view?usp=sharing
Why is the corract answer not Class(D,C): pass ??
D -> B -> A
C -> A
I do not understand why the correct answer is Class(C,D): pass
Can someone please explain?
Is that because in the inheritance
class B cannot be invoked before class C is invoked which is why it's Class(C,D): pass
C -> A
D -> B -> A
(class B invoked later on as it is initialized earlier than class C)
On multiple inheretance, the Parent cannot be declared before the child:
https://www.datacamp.com/community/tutorials/super-multiple-inheritance-diamond-problem
Can't be B, class A shouldn't be before class C, because class C is a subclass of class A.
The order left and right is important in python.
upvoted 3 times
...
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Damon54
9 months, 3 weeks agoseaverick
10 months agoJanpcap123
1 year, 2 months agoCaptainPirate
1 year, 3 months agoRaymond91
1 year, 4 months agoBoka
2 years, 3 months agomacxsz
2 years, 6 months agoMTLE
2 years, 7 months agoruydrigo
2 years, 10 months agomacxsz
2 years, 6 months agoerikkk
3 years, 1 month agomouhsini
3 years, 1 month ago