On 2022-04-10 08:50, malmiteria wrote:
The order of inheritance as in, one class inherits from another do matter,
quite obviously, since it's not a symetrical operation, and accordingly, the
syntax is not symettrical.
The order in which parents are placed in case of multiple inheritance is far
from being that obviously assymetrical, and the syntax does not hint it is,
quite less than inheritance syntax.
IE:
"class A(B)" feels very different from "class B(A)"
but "class A(B,C)" doesn't feel so obviously different from "class A(C,B)"
Despite it mattering the exact same amount.
I'm not the first person to say this, but your example here again makes
clear to me that your real issue has nothing to do with super or MRO.
Your problem is with multiple inheritance at a conceptual level.
You seem to be envisioning a system in which multiple inheritance gives
a subclass a "menu" of behaviors from which it may explicitly choose,
but does not actually combine the superclasses' behaviors into a single,
definite behavior of the subclass. In that scheme, order of multiple
inheritance would not matter, because the superclasses don't need to be
"integrated" into the subclass; they just sit there waiting for the
subclass to explicitly decide which superclass it wants to delegate to.
Maybe that's how MI works in some other languages, but not Python.
Everything about a class --- super, MRO, everything --- is impacted by
its ENTIRE superclass hierarchy, including the order in which classes
are inherited. When a subclass inherits from multiple superclasses, the
superclass behaviors are *combined* into a *single* set of behaviors for
the subclass. They're not "held separate" somehow as alternative
inheritance hierarchies; they are joined into one.
Likewise, the order in which a class inherits multiple superclasses
matters in Python. That's just how Python works, and there's no way
that's going to change. I don't want to sound harsh, but if `class A(B,
C)` doesn't "feel" different to you from `class(C, B)` then I think you
need to adjust your feelings rather than expect Python to adjust its
behavior.
--
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is no
path, and leave a trail."
--author unknown
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/4PF5PQAV2RXLZVRH4LDQHC5VXK4VSVDP/
Code of Conduct: http://python.org/psf/codeofconduct/