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

Roy Smith roy at panix.com
Sat Jul 17 15:14:47 EDT 2004


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?

The google link you provided talked about eval and exec.  My experience 
is that when I first started using Python (about 7 years ago), I used 
eval and exec a lot.  Now, I can't remember the last time I ever wanted 
to use either.

Can you give us an example of what you're trying to do?  My guess, 
having not yet seen it, is that there's probably a better way to do it 
than what you're asking.



More information about the Python-list mailing list