On Thu, Apr 07, 2022 at 11:52:31AM -0000, malmiteria  wrote:

> I believe my gobelin exemple is a fair case of MI since we can 
> definitely say halfbreed *is a* corruptedgobelin *and a* proudgobelin.

That is the most common relationship modelled by inheritance.


> In such a case with multiple *is a* there's multiple strategies to 
> blend in the multiple *is a*.

And super does that correctly.

Except that you prefer to use a different design that is not well- 
modelled by inheritance, but is well-modelled by delegation. And then 
for some reason, you insist on using super.


> Another strat is to say that some attributes / behaviors of one parent 
> override the over, like dominant genes.

Don't be fooled by the name, inheritance in programming languages does 
not model DNA. It is a simple model useful for programming.


> Today's MRO implicitely overrides all method from the second parent 
> with method from the first parent.

Right, because it models **cooperative inheritance**, not DNA. A method 
in one class overrides that in classes later in the MRO unless it 
cooperatively passes the call on to the next class in the MRO.


> Essentially, the first parent (in declaration order) is dominant on 
> all attributes. This isn't very subtle, as we could want some 
> attribute of each parent to be dominant, while others to be recessive.

This is all very hypothetical. You could want Intercal's COMEFROM 
statement too, but why would you?

MI is complicated enough without intentionally trying to make it 
arbitrarily more complicated, when instead you can just use composition 
or delegation instead.

You want to write this:

    super(ProudGobelin, self).method()

But you can already do that, using less typing, and get exactly the same 
effect:

    ProudGobelin.method(self)

That does everything you want, and saves you seven characters. Less 
typing, more efficient, works today in standard Python, no special 
imports needed or changes to the interpreter or language. All you need 
to do is **don't use super** for things that don't need super.

The only reason you won't use it is that you insist on using the 
screwdriver of super() to hammer in the nails of delegation.



-- 
Steve
_______________________________________________
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/MQALSNQXYYKBKOLAZV6EIG2WCNXSAWAK/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to