On 4/12/2022 7:43 AM, malmiteria wrote:
Brendan Barnwell writes:
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.
not sure i had time to answer this one yet, so here we are.
I do not want any change in case of simple inheritance, nor do i want any
change in case of MI where there's no name collision.
The integration of parent class would be the exact same in those cases.
And if you doubt it, my proposal, about method resolution, is that if there's
only one candidate for resolution, we select it, if there's none, we raise the
standard attribute error, and if there's multiple, we raise an explicitness
required error.
In case of MI where there's no name collision, aka, there's never more than one
candidate for resolution, the behavior would be the exact same.
Expliciteness is required only in case there's multiple candidates for
resolution.
I've said this before, but I'll repeat it here: if your proposal is to
have super().something raise an error if "something" exists on more than
one parent class (via the MRO), then that's a breaking change and it
will not be accepted.
This code:
```
class A:
def foo(self):
print("A")
try:
super().foo()
except AttributeError:
print('no parent defines foo')
class B:
def foo(self):
print("B")
try:
super().foo()
except AttributeError:
print('no parent defines foo')
class C(A, B):
def foo(self):
print("C")
super().foo()
C().foo()
```
Must continue to output:
```
C
A
B
no parent defines foo
```
Eric
_______________________________________________
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/RM4HPZV7MAQTKDMEDZSVAD7K2JIPKMXI/
Code of Conduct: http://python.org/psf/codeofconduct/