[Tutor] assignment to 1 item in dict assigns to all items in dict?
Chris Somerlot
cdsomerl@murray-ky.net
Fri Apr 11 15:33:02 2003
OK, so it seems to me I have 2 options for building my data model:
nesting lists and dictionaries (making sure to create new instances
instead of references), or an object model by implementing classes
> You could do this with a class, and that would probably be my
preferred
> way, especially if there's any common tasks that need to be done on
> line_items -- those can easily become methods of the class.
> Note that this makes it easier to refer to parts of each line item,
> since you can use a named attribute instead of the cryptic [2], and it
> also allows for more flexibility in creating items that are already
> initalized.
I'm going to need to iterate through (and sum) attributes that are
(currently) lists in dictionaries, as well as attributes that are in
separate, similar lists in a dictionary. Would this be easier if I
switched over to the object data model? And will using one way over the
other lead to speed or private variable issues that I have not figured
out yet?
Thanks for your help
Chris