On Sat, Mar 26, 2022 at 10:24 AM malmiteria <martin.mi...@ensc.fr> wrote:

> i mean yeah, of course you don't need super.
> And i also understand that feeling that composition is better than
> inheritance.
>

That's a bit beside the point -- we can use inheritance, and also be more
explicit about calling superclass methods if need be.


> But that's beside my point, super acts as a proxy to a parent, and is by
> default the feature to refer a parent from within a class method.
>

Almost -- I think super() acts a proxy to the *perents*, plural. even if
the current class inherits from only one class, that superclass may inherit
from more than one class.

If you just want the superclass, you can call it directly:

class B(A):
    def some_method(self, ...):
        A.some_method(self)

And if you do that, you will get a good fraction of the behaviour you are
expecting.

The point of super() is to provide a way to, yes, implicitly, call a method
on all the superclasses in the inheritance tree. There's more than one way
to do that, but it's perfectly reasonable that Python provide only one way,
with clear rules, which is what we have now. And if there's going to be one
way, the MRO currently in use is a pretty darn good one.

Yes, sometimes the specified MRO isn't what you need -- but It's my
impression that your proposal really doesn't add anything over simply
calling superclasses directly the way you want. But if you want to show how
useful it could be, then go ahead and continue working on your
prototype,and share it with the world.

If people find it useful, then maybe it would be worth considering as a
addition to Python.

NOTE: I would work hard to find real examples where you can show how the
current super() doesn't work well, and how explicitly calling superclass
methods is substantially uglier than using your parent() approach.

-CHB

-- 
Christopher Barker, PhD (Chris)

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
_______________________________________________
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/Z3DP5GA2CYHFI4OLJKWBMG4HOU754QV2/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to