Would a shade of difference in shape of mixins ruin the result of a program when doing Object Oriented Programming?

I’m learning Object Oriented Programming with Mixins. The correct answer is with dunders on each side of main. My answer of the program has no dunders. Top 1 is the mixins of my e-book. Top 2 is the mixins drawn by myself. Can any experts pore over my program and kindly tell me which part(s) of my program is wrong? Thanks.
the Mixins of my e-book
Mixins drawn by myself

When you run a Python file as a script, the module the code is executed in is called __main__. That’s why this shows up in the class reprs. __mro__ stands for “Method Resolution Order”, by the way. It’s the order classes are checked for methods. I do notice in your code that you don’t have a B class, is that intentional?

1 Like

Brown, I upload my entire program which contains A --------E.

Just from a quick glance at the screenshot, it looks like class D is missing B.

class D(B, C)

1 Like

Paul, you are a genius. The problem is fully solved, and dunders appear on the each side of main. Question: how did you come up with this solution ? For me, I can’t get the correlation of D(B,C) and dunders.
Moreover, the shade of Mixins’ shape matters and why? Any quick explanation?

1 Like

From the inheritance tree image that you provided. Notice that D has both B and C pointing towards it. This implies that D is inheriting from them both.

1 Like

Have you fixed bugs offen? And in my drawing, why is E red?

Mostly in C. But now in Python, it is just a matter of knowing the proper syntax. Kind of like English. You learn to spot misspellings, run-on sentences, syntax/grammatical errors, etc.

Why is E red?

Maybe to signify that it is the last class in the inheritance tree?

1 Like

@onePythonUser The E in my e-book is black.

Well, they tell you that the order of the inherited classes matters.
They have:

class E(D, C)

but then they point out that you can’t have the following order:

class E(C, D)

Have you tried swapping the order and testing it?

1 Like

This explanation is much more acceptable. Million thanks. No, I never tried swapping the order and testing it.

Here Endeth the Lesson.

1 Like