[Tutor] Dynamically named objects
Michael Bernhard Arp Sørensen
michaelarpsorensen at stevnstrup.dk
Fri Dec 28 08:44:48 CET 2007
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20071228/a277d77d/attachment-0001.htm
More information about the Tutor
mailing list