
On 2022-03-26 11:15, malmiteria wrote:
the alternative to super really is not the important part of my proposal, it's the alternative to MRO.
An example of a case where i genuinly believe my solution adds value is this :
``` class A: def method(self): print("A")
class B: def method(self): print("B")
class C(A, B): pass ```
Today, a code such as ```C().method()``` works without any problems except of course when the method you wanted to refer to was the method from B.
But that's what people have been saying: if you want to call the method from B, just call the method from B.
If class A and B both come from libraries you don't own, and for some reason have each a method named the same (named run, for example) the run method of C is silently ignoring the run method of B.
I believe it would make the programmers life easier to have an error at this time, or anything tbh, to make explicit this resolution, because it really is not explicit from most programmers perspective
To me it doesn't seem reasonable that someone would inherit from two classes and want to call a method from one without even knowing that there's a method name collision. If you're going to inherit from A and B, you need to know what methods they provide and you need to think about the order you inherit in. If you inherit from two classes that have a name collision because they provide unrelated methods that happen to share a name, I think you have a problem right there that needs to be resolved (like by having the inheriting class explicitly delegate to a specific superclass). But I don't think that is a very common situation. Based on your example, I still don't really see the advantage of your proposal. Currently super is the way to say "let Python choose for me what method implementation to call next, based on the class hierarchy". You seem to be saying that in some cases that won't call the right thing so you don't want it to call anything. But if super doesn't call the right thing, you can just not use super and instead explicitly call the method you want, so I don't get what this proposal gains. -- Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown