initialising a class by name

Chris Rebert clp2 at
Wed Jan 14 09:39:50 CET 2009

On Wed, Jan 14, 2009 at 12:36 AM, Krishnakant <krmane at> wrote:
> On Wed, 2009-01-14 at 00:20 -0800, Chris Rebert wrote:
>> Aside from Steven's excellent idea, to use the getattr() technique
>> with your module scheme you'd probably also need to use __import__()
>> to dynamically import the right module.
> I would generally import all the modules I would need at the top of the
> main module.
> then would use getattr(module,class_name) will that work?

Yes, that is how you'd do it in that case.

Follow the path of the Iguana...

More information about the Python-list mailing list