Rilindo Foster wrote: > Scratch that, I'm a dork: > > OrderDict[(o[0])] = OrderDict.get(o[0],0) + float(o[1]) > > http://www.faqts.com/knowledge_base/view.phtml/aid/4571/fid/541 > > :D >
For this case you might also be interested in collections.defaultdict, added in python 2.5 I believe. from collections import defaultdict orders = defaultdict(float) orders[o[0]] += float(o[1]) HTH, Marty _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor