Re: Class list of a module

2007-01-15 Thread Gabriel Genellina
At Monday 15/1/2007 04:27, you wrote: I want to get all classes of a module in a list. I wrote this code but I wonder if there's not a simpler solution import inspect def getClassList(aModule): return [getattr(aModule, attName) \ for attName in aModule.__dict__ \

Re: Class list of a module

2007-01-15 Thread bearophileHUGS
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,

Re: Class list of a module

2007-01-15 Thread Laurent . LAFFONT-ST
Looks rather simple to me... Anyway, you could avoid calling getattr twice, if you iterate over vars(aModule).itervalues() def getClassList(aModule): return [cls for cls in vars(aModule).itervalues() if inspect.isclass(cls)] (And note that there is no need for using \ at the line

Re: Class list of a module

2007-01-15 Thread George Sakkis
[EMAIL PROTECTED] wrote: 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:

Class list of a module

2007-01-14 Thread Laurent . LAFFONT-ST
Hi, I want to get all classes of a module in a list. I wrote this code but I wonder if there's not a simpler solution import inspect def getClassList(aModule): return [getattr(aModule, attName) \ for attName in aModule.__dict__ \ if