An interface for `mro` methods similar to the interface for `iter`, `getattr`, etc...

*Greetings Fellow Earthlings,* *In python 3.11, python has a number of built-in functions which act as an Interface for magic dunder methods. Two examples of what I am talking about are shown below: * *Begin Example 1 of 2* *rocky = object()x = getattr(rocky, "length") x = rocky.__getattr__("length") * *Begin Example 2 of 2* *box = [1, 2, 3]it = iter(box) it = box.__iter__()* *My suggestion is that in future versions of python, we will have `mro()` behave in a similar fashion. * *obj = object()x = mro(obj) x = obj.__mro__() * *Additionally, the class named `object` should have a method named `__mro__` and any class which inherits from `object` may override `__mro__` or inherit the default `* *object* *.__mro__` . * *Samuel Muldoon* *(720) 653 -2408* *muldoonsamuel@gmail.com <muldoonsamuel@gmail.com>*

Hi Samuel, Classes already have a `obj.mro()` public method that wraps their private dunder `__mro__`. Non-classes (instances) don't have a `__mro__`.
Guido's time machine strikes again. This has existed since Python 2.2 or thereabouts, so more than twenty years ago:
object.__mro__ (<class 'object'>,)
object.mro() [<class 'object'>]
-- Steve

Hi Samuel, Classes already have a `obj.mro()` public method that wraps their private dunder `__mro__`. Non-classes (instances) don't have a `__mro__`.
Guido's time machine strikes again. This has existed since Python 2.2 or thereabouts, so more than twenty years ago:
object.__mro__ (<class 'object'>,)
object.mro() [<class 'object'>]
-- Steve
participants (3)
-
Rob Cliffe
-
Samuel Muldoon
-
Steven D'Aprano