[issue18929] inspect.classify_class_attrs ignores metaclass

Antoine Pitrou report at bugs.python.org
Sun Sep 8 18:49:38 CEST 2013


Antoine Pitrou added the comment:

> It seems that currently inspect is geared towards instances and
> classes, not metaclasses.  Consequently, so is help.

I'm afraid I don't really understand what you're talking about. A
metaclass is just a slightly different kind of class :-)

> def classify_class_attrs(cls):
>     """Return list of attribute-descriptor tuples.
> 
>     For each name in dir(cls), the return list contains a 4-tuple
>     with these elements:
[...]
> We could add additional 'kind' of 'hidden class method', and 'hidden
> class attributes' and then have classify_class_attrs explicitly search
> metaclasses.

The docstring is clear: "For each name in dir(cls)". If you want stuff
that hidden's in the cls.__class__ (and, consequently, not in dir(cls)),
then you are not looking for the right function, I think.

I can understand wanting to better automate lookup of methods on
classes, rather than on instances, but it would probably deserve another
function.

But I have another question first: doesn't calling
classify_class_attrs() on the metaclass already do what you want?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18929>
_______________________________________


More information about the Python-bugs-list mailing list