dynamic class/module use? (like Java's forName)

Alex Hunsley lard at tardis.ed.ac.molar.uk
Sat Jul 17 22:33:51 EDT 2004


Roy Smith wrote:

> In article <_OdKc.29430$v7.8250 at fe2.news.blueyonder.co.uk>,
>  Alex Hunsley <lard at tardis.ed.ac.molar.uk> wrote:
> 
> 
>>Does python provide a way to dynamically use modules and/or classes?
>>I'm thinking in the vein of Java's Class.forName.
> 
> 
> Just out of curiosity, why do you want to do that?
> 

p.s. to my last response:

I've just read Robert Brewer's reply, and to rephrase myself as I to 
him: I'm trying to do the strategy pattern in a modular fashion. (i.e. 
no big string of 'ifs' and hardcoded actions.)

alex



More information about the Python-list mailing list