Author ethan.furman
Recipients eli.bendersky, ethan.furman, pitrou
Date 2013-09-08.16:39:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1378658376.75.0.951636721817.issue18929@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-09-08 16:39:36ethan.furmansetrecipients: + ethan.furman, pitrou, eli.bendersky
2013-09-08 16:39:36ethan.furmansetmessageid: <1378658376.75.0.951636721817.issue18929@psf.upfronthosting.co.za>
2013-09-08 16:39:36ethan.furmanlinkissue18929 messages
2013-09-08 16:39:36ethan.furmancreate