On Sat, Oct 3, 2020 at 9:28 AM Serhiy Storchaka <storch...@gmail.com> wrote:

> 03.10.20 18:15, Guido van Rossum пише:
> > Is this the only place where a non-class object with __bases__ is
> > accepted? Or do we have more such? I recall that long ago you could use
> > certain non-class objects as base classes.
>
> The only other place is object.__dir__(). It recursively iterates the
> __class__.__bases__ chain, and __class__ can be a non-type object.
>
> The code of object.__dir__() is very old, it predates new-style classes,
> and currently it gathers names using different algorithm than used in
> object.__getattr__(), so object.__dir__() does not always return a list
> of names accepted by object.__getattr__().
>

Would anything break if we changed `dir()` to use `__mro__` instead of
`__bases__`? It would probably be simpler.


> > I think all that hackery may predate (and may even have been an
> > inspiration for features of) new-style classes.
>
> I wonder whether it should pass with Python 2.
>

I suppose you meant "pass" as in "die". I agree.

-- 
--Guido van Rossum (python.org/~guido)
*Pronouns: he/him **(why is my pronoun here?)*
<http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/2PYPN5NM2A2Q75YPB5TD5OCDT2L4ZZG6/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to