[Python-Dev] inspect() and dir()

Nick Coghlan ncoghlan at gmail.com
Wed Oct 9 23:46:29 CEST 2013


On 10 Oct 2013 03:39, "Ethan Furman" <ethan at stoneleaf.us> wrote:
>
> On 10/09/2013 09:40 AM, Brett Cannon wrote:
>
>> On Tue, Oct 8, 2013 at 5:29 PM, Ethan Furman wrote:
>>>
>>>
>>> Currently, inspect() is dependent on dir().
>>
>>
>> What's inspect()? I don't know of any global with that name and you are
obviously not talking about the module.
>
>
> My apologies.  I am actually talking about the module.  I meant
inspect.get_members() and inspect.classify_class_attrs(), which, as near as
I can tell, are the only two functions in inspect that attempt to
retrieve/look at all of an object's attributes.

Those have to depend on __dir__ so classes (especially proxies) can
accurately report *extra* dynamically accessible names.

It's also the mechanism by which custom metaclasses, descriptors and
__getattribute__ implementations can report the right names to the
introspection machinery.

However, it may make sense to offer a separate introspection utility to
help debug custom __dir__ implementations.

Cheers,
Nick.

>
>
> --
> ~Ethan~
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
https://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20131010/53ad9060/attachment.html>


More information about the Python-Dev mailing list