[Tutor] Object Instantiation via Dictionary Values
Sean Abrahams
Sean Abrahams <sa@sfsu.edu>
Fri Feb 28 18:40:02 2003
I want to create new objects with names and classes that are stored
inside a list of dictionaries.
Example:
modules = [{'Name' : 'Sean', 'Type' : 'Person'},
{'Name' : 'Buddy', 'Type' : 'Dog'},
{'Name' : 'Evil', ' Type' : 'Cat'}]
for module in modules:
module['Name'] = module['Type'].module['Type']()
# Would be:
# Sean = Person.Person()
# Buddy = Dog.Dog()
# Evil = Cat.Cat()
I'm not exactly sure how to go about this, but assume it has something
to do with using special methods.
Thanks,
--Sean