Hi there.

I need to instantiate objects on the fly and put the in a list/dict for
later use. I was thinking of this:

objectlist = []
newobjectname = "object1"
classname = "class1" + "()"
objectlist.append(newobjectname = eval(classname) )
objectlist[0].method("hello world")

Can this be done? If not, is there a work around or some design pattern for
this situation?

-- 
Venlig hilsen/Kind regards

Michael B. Arp Sørensen
Programmør / BOFH

I am /root and if you see me laughing you better have a backup.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to