list classes in package
Diez B. Roggisch
deets at nospam.web.de
Wed Jan 16 16:36:36 CET 2008
> Hi All,
> I've trying to develop one Python application, and
> neet to solve one problem. I need to list all classes defined in one
> package (not module!).
> Could anybody please show me more convinient (correct) way to
> implement this?
Look at the module inspect and it's predicates. Something like
for name in dir(module_or_package):
if inspect.isclass(getattr(module_or_package, name)):
print "%s is a class" % name
More information about the Python-list