how to find available classes in a file ?
John J. Lee
jjl at pobox.com
Sun Jul 22 07:42:01 EDT 2007
Alex Popescu <the.mindstorm.mailinglist at gmail.com> 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
possible.
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).
John
More information about the Python-list
mailing list