Classes are not members of their respective modules??

Robert Dickinson rdickins at usaor.net
Tue Aug 20 01:01:18 CEST 2002


I am trying to get info about the classes in my running system. Having
gotten the modules, I wanted to get the classes defined in them. However,
    classes = inspect.getmembers(module,inspect.isclass)
returns an empty list. This surprised me, so I inspected the __dict__ of the
module; the classes are not there, either (presumably that is where
getmembers() is getting its info). Am I missing something obvious? How
should I be getting the classes?

So that you understand why I'm asking, I am trying to implement a trace
(debugging purposes) that shows
    call module.class.method(args...)
    return module.class.method -> retvalue
for each method/function entered. Since I can only get the underlying
function (not class.method) in the sys.settrace() module, I am trying to
pre-parse my classes to find starting line numbers for methods, in order to
be able to correlate them with the functions I get in sys.settrace().  If
there is a much easier way to do this, I am open to suggestions, but please
answer the above question, also; it's got me bugged!





More information about the Python-list mailing list