[Python-ideas] Should we improve `dir`?

Chris Angelico rosuav at gmail.com
Sun Sep 15 04:59:49 CEST 2013


On Sun, Sep 15, 2013 at 11:47 AM, Mark Janssen
<dreamingforward at gmail.com> wrote:
>> Right, this is one of the behavioural differences between classes and
>> instances, and, as far as I am aware, it isn't an accident.
>
> In fact, I'd argue that is a critical distinction.  A language
> definition has to help enforce this distinction, otherwise confusion
> abounds.
>
>> If introspection tools want to show all the operations available *on the
>> class*, then they need to include "dir(type(cls))" as well.
>
> If users want to find the operations available "on the class", they
> should learn Python.

The other day I was looking for __bases__ but couldn't remember what
it was called. I did the obvious thing and used IDLE's tab
completion... and it wasn't there. There definitely is value in having
those sorts of things be in dir().

ChrisA


More information about the Python-ideas mailing list