how to find available classes in a file ?

John J. Lee jjl at
Sun Jul 22 13:42:01 CEST 2007

Alex Popescu <the.mindstorm.mailinglist at> writes:
> I may be wrong but I think I've found a difference between my
> dir(module) approach
> and the inspect.getmembers(module, inspect.isclass): the first one
> returns the
> classes defined in the module, while the later also lists the imported
> available
> classes.

FWIW, see doctest.DocTestFinder._from_module() for a way to tell if an
object is from a module.  This can be fooled if you've managed to get
hold of two copies of a module, though, which unfortunately is

I hope the import system is much cleaner in Python 3 :-/ (seems there
are efforts in that direction, though I'm not up-to-date with it).


More information about the Python-list mailing list