<p dir="ltr"><br>
On 15 Sep 2013 09:13, "Terry Reedy" <<a href="mailto:tjreedy@udel.edu">tjreedy@udel.edu</a>> wrote:<br>
><br>
> On 9/14/2013 4:54 PM, Raymond Hettinger wrote:<br>
><br>
>> On Sep 14, 2013, at 12:15 PM, David Halter<br>
>> <<a href="mailto:davidhalter88@gmail.com">davidhalter88@gmail.com</a><br>
>> <mailto:<a href="mailto:davidhalter88@gmail.com">davidhalter88@gmail.com</a>>> wrote:<br>
>><br>
>>> After discussions, I realized that I should probably bring this up in<br>
>>> python-ideas, I think the current implementation can be very confusing<br>
>>> for people trying to introspect classes with `dir`, which is IMHO its<br>
>>> typical use case.<br>
>><br>
>><br>
>> The current behavior of dir() is a bit irritating when I am teaching how<br>
>> Python works.<br>
>><br>
>> That said, the irritation is minor and easily overcome.<br>
>><br>
>> I would not want to change the behavior and risk breaking<br>
>> existing introspection code (that code is tends to be more<br>
>> fragile and implementation than most other code).<br>
><br>
><br>
> This was the basis for rejecting <a href="http://bugs.python.org/issue19002">http://bugs.python.org/issue19002</a><br>
> ``dir`` function does not work correctly with classes.<br>
> The proposal obviously broke pydoc and inspect modules.<br>
><br>
><br>
>> In other words, I just don't think it is worth changing something<br>
>> that has been in-place for a very long long time.  The minor<br>
>> benefit doesn't want the downsides that goes with API churn.<br>
><br>
><br>
> The other point is that people *usually* call dir(cls) in order to find the methods they can call in instances of cls:</p>
<p dir="ltr">Right, this is one of the behavioural differences between classes and instances, and, as far as I am aware, it isn't an accident. Not only that, but (as Raymond pointed out) even if it was originally an accident it's too late to change it now.</p>

<p dir="ltr">If introspection tools want to show all the operations available *on the class*, then they need to include "dir(type(cls))" as well. So there may be a legitimate feature request for a new section in the pydoc output showing "class only" methods and attributes.</p>

<p dir="ltr">Cheers,<br>
Nick.</p>
<p dir="ltr">><br>
> -- <br>
> Terry Jan Reedy<br>
><br>
> _______________________________________________<br>
> Python-ideas mailing list<br>
> <a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/python-ideas">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
</p>