selecting a class in execution time

cybersamurai at cybersamurai at
Mon Apr 7 21:56:56 CEST 2003

Thanks about your help

I am developing a way to describe a application in XML language. De 
idea is define only the data and your type, using a engine in execution 
time to create a functionality of some application.

take a look in this diagram to get the idea.
in this idea is only needed create a green file to make a application

On segunda-feira, 7 abr, 2003, at 14:23 America/Sao_Paulo, Brian 
Quinlan wrote:

> I'd be nice to know the why of this to suggest the best idiom.
>> Object x = Class.forName( "mypackage.TheClass" ).newInstace();
> x = getattr(__import__("mypackage"), "TheClass")()
> The last set of parens is the argument list for TheClass' constructor.
> If you know the name of the package at compile time then:
> import mypackage
> x = getattr(mypackage, "TheClass")()
> Cheers,
> Brian

More information about the Python-list mailing list