Instantiating variable classes

Harald Massa cpl.19.ghum at spamgourmet.com
Thu Mar 20 03:04:18 EST 2003


Hello,

I need to instantiate "variable classes". That is:


myClass=replcsX()

where X is 0,1,2,3,4,...7

depending on the program flow.

One possibility is:

if X==0:
    	myClass=replcls0()
elif x==1:
    	myClass=replcls1()
and so on ..


Second possibility is:

command="replcs%d()" % (X,)
myClass=eval(command)


I'm using the second one, but I am sure there is a way to use Python's 
more than powerfull class- and objekt manipulations.

But I did not find out how.

Any suggestions?

Harald




    	




More information about the Python-list mailing list