Message197280
Okay, taking a step back.
It seems that currently inspect is geared towards instances and classes, not metaclasses. Consequently, so is help.
So, how do we enhance inspect so that help can be metaclass aware?
classify_class_attrs seems like an obvious choice, and it's docstring currently says this:
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:
0. The name (a string).
1. The kind of attribute this is, one of these strings:
'class method' created via classmethod()
'static method' created via staticmethod()
'property' created via property()
'method' any other flavor of method
'data' not a method
2. The class which defined this attribute (a class).
3. The object as obtained directly from the defining class's
__dict__, not via getattr. This is especially important for
data attributes: C.data is just a data object, but
C.__dict__['data'] may be a data descriptor with additional
info, like a __doc__ string.
"""
We could add additional 'kind' of 'hidden class method', and 'hidden class attributes' and then have classify_class_attrs explicitly search metaclasses.
Or, since we have to make a new getmembers (getmetaclassmembers?), we could also make a new classify_metaclass_attrs that handled both class and metaclass. |
|
Date |
User |
Action |
Args |
2013-09-08 16:39:36 | ethan.furman | set | recipients:
+ ethan.furman, pitrou, eli.bendersky |
2013-09-08 16:39:36 | ethan.furman | set | messageid: <1378658376.75.0.951636721817.issue18929@psf.upfronthosting.co.za> |
2013-09-08 16:39:36 | ethan.furman | link | issue18929 messages |
2013-09-08 16:39:36 | ethan.furman | create | |
|