Class list of a module

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Mon Jan 15 03:38:56 EST 2007


Gabriel Genellina:
> >import inspect
> def getClassList(aModule):
>      return [cls for cls in vars(aModule).itervalues()
>                      if inspect.isclass(cls)]

This is short enough too:

from inspect import isclass
getclasses = lambda module: filter(isclass, vars(module).itervalues())

Bye,
bearophile




More information about the Python-list mailing list