Re: inverting a dictionary of lists

2007-06-14 Thread Raymond Hettinger
On Jun 14, 8:20 pm, [EMAIL PROTECTED] wrote: > I have a very large dictionary of lists: > d = {a:[1,2], b:[2,3], c:[3]} > and i want to reverse the associativity of the integers thusly: > inverse(d) makes {1:[a], 2:[a,b], 3:[b,c]} Try using setdefault: >>> d = {'a':[1,2], 'b':[2,3], 'c':[3]

Re: inverting a dictionary of lists

2007-06-14 Thread Gabriel Genellina
En Fri, 15 Jun 2007 00:20:33 -0300, <[EMAIL PROTECTED]> escribió: > I searched for an hour and don't see a solution to this (i assume > somewhat common) problem. > > I have a very large dictionary of lists: > d = {a:[1,2], b:[2,3], c:[3]} > and i want to reverse the associativity of the integers t

inverting a dictionary of lists

2007-06-14 Thread bpowah
I searched for an hour and don't see a solution to this (i assume somewhat common) problem. I have a very large dictionary of lists: d = {a:[1,2], b:[2,3], c:[3]} and i want to reverse the associativity of the integers thusly: inverse(d) makes {1:[a], 2:[a,b], 3:[b,c]} my solution expands the