Replacing Axiom Lists with a new list of Items
Robert Gravina <[email protected]> Sun, 2 Jul 2006 03:12:30 +0900
| Newsgroups | gmane.comp.python.quotient.dev |
|---|---|
| Message-ID | <[email protected]> |
In Axiom, is there any quick way to update the contents of one List
with the contents of another, so that existing items can be updated,
non existing ones deleted, and new ones added?
The best I can come up with is something like this (excuse my Potato
Programming... I still haven't become fluent in Python). In this
case, "oldlist" is a List of Items and "newlist" contains objects
which aren't Items, but hold the same attributes (there are actually
Twisted pb.RemoteCopy's). Assume my Item class has an "update" method
that will take these objects from "newlist" and copy the attirbutes
across.
done = []
for o in newlist:
if o.storeID:
i = store.getItemByID(o.storeID)
i.update(o)
else:
oldlist.append(SomeItem(store=store, ....))
done.append(o.storeID)
for o in oldlist:
if o.storeID not in done:
oldlist.remove(o)
This works, but I am just wondering if there was a better way?
Robert