Python version of STL multimap?
Alex Martelli
aleax at aleax.it
Sat Jul 6 17:31:48 EDT 2002
Boudewijn Rempt wrote:
...
> Isn't this exactly what Alex Martelli posted the other day:
>
> dict.setdefault(key, []).append(value)
>
> in answer to the thread about sorting a dictionary by its value?
That's one possibility, yes -- a dict of lists. But if values
are also hashable (a prereq I forgot to mention in my last post:-)
and you don't care about order (and more often you don't, though
sorting is an obvious exception:-), a dict of dicts may be better,
as per my last post.
Alex
More information about the Python-list
mailing list