[Python-bugs-list] [ python-Bugs-759525 ] inspect.getmembers broken (?)

SourceForge.net noreply@sourceforge.net
Mon, 30 Jun 2003 08:27:34 -0700


Bugs item #759525, was opened at 2003-06-23 18:43
Message generated for change (Comment added) made by gvanrossum
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=759525&group_id=5470

Category: Python Library
Group: None
Status: Open
Resolution: None
>Priority: 1
Submitted By: Alexander Schmolck (aschmolck)
Assigned to: Nobody/Anonymous (nobody)
Summary: inspect.getmembers broken (?)

Initial Comment:
inspect.getmembers currently uses `dir` to obtain a
list of an object's "members", which omits certain
things such as methods of the metaclass, e.g:

  >>> 'mro' in dict(inspect.getmembers(int))
  0

Since I can't find a description of what exactly
constitutes a "member", it is not strictly possible to
tell whether this is the intended behavior, but then
the documentation should be updated in this case to
clarify the semantics more.

It currently seems quite hard to answer seemingly
innocuous questions such as "What are the methods of
class/type X?" with introspection. 

----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2003-06-30 11:27

Message:
Logged In: YES 
user_id=6380

This is unclear indeed -- inspect is definitely underspecified.

It *is* clearly defined that dir() doesn't return metaclass
attributes when the argument is a class.

To find out the metaclass arguments, simply use
dir(int.__class__).

I'll leave this open, but I expect that at best some
documentation clarification will come out of this.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=759525&group_id=5470