[Python-Dev] dict.addlist()

Fred L. Drake, Jr. fdrake at acm.org
Tue Jan 20 13:37:10 EST 2004


Raymond Hettinger writes:
 > After all the discussions, the best solution to the defaulting problem
 > appears to be some variant of Martin's general purpose approach:
 > 
 > d = {}
 > d.setfactory(list)
 > for k, v in myitems:
 > 	d[k].append(v)		# dict of lists

Oooh, this could get scary:

L = []
L.setfactory(MyClassWithCostlyConstructor)
L[0]


;-)


  -Fred

-- 
Fred L. Drake, Jr.  <fdrake at acm.org>
PythonLabs at Zope Corporation



More information about the Python-Dev mailing list