Loading a class the name of which is only known runtime

Mads Orbesen Troest mads at troest.NEVERMORE.dk
Tue Apr 8 12:31:23 EDT 2003


Hi folks;

"And now for something completely different:"

I have a situation in which I, from a CGI script written in Python, want to 
instantiate a class, the name of which is known to me only at runtime 
(because it depends on a CGI parameter).

Is it possible to load (import and instantiate) a class dynamically in 
Python? I have a feeling the answer is Yes, but as I am unfortunately not 
quite the python expert (yet :) forgive me if I ask something obvious.

Thanks in advance,
   /\/\\ads Orbesen Troest




More information about the Python-list mailing list