[Python-ideas] An interface for `mro` methods similar to the interface for `iter`, `getattr`, etc...

2023-03-24 Thread Samuel Muldoon
*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__("

[Python-ideas] Re: An interface for `mro` methods similar to the interface for `iter`, `getattr`, etc...

2023-03-24 Thread Steven D'Aprano
Hi Samuel, Classes already have a `obj.mro()` public method that wraps their private dunder `__mro__`. Non-classes (instances) don't have a `__mro__`. > Additionally, the class named `object` should have a method named > `__mro__` and any class which inherits from `object` may override > `__mro

[Python-ideas] Re: An interface for `mro` methods similar to the interface for `iter`, `getattr`, etc...

2023-03-24 Thread Rob Cliffe via Python-ideas
On 24/03/2023 17:30, Samuel Muldoon wrote: *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__` . * It already has an attribute of that name: >>> object._