initialising a class by name

Krishnakant hackingkk at gmail.com
Wed Jan 14 04:51:38 EST 2009


On Wed, 2009-01-14 at 04:09 -0500, Steve Holden wrote:
> > 
> You don't need to have the names of the classes related to anything in
> the interface. Just use a list of classes, and have the user interface
> return the correct index for each class. Then (supposing the selection
> by the user is seln) use
> 
>   Books = classes[seln]()
> 
> If the classes are all in different modules, import them before creating
> the list of classes.
> 
Is there a way to get the list of all the classes in the package?
I mean is there a way to build a list of modules  from some global
variable which can be accessed and then looped through.
happy hacking.
Krishnakant.

> regards
>  Steve




More information about the Python-list mailing list