[Python-Dev] Proposal: defaultdict
Fredrik Lundh
fredrik at pythonware.com
Fri Feb 17 12:14:27 CET 2006
More information about the Python-Dev mailing list
Fri Feb 17 12:14:27 CET 2006
- Previous message: [Python-Dev] Proposal: defaultdict
- Next message: [Python-Dev] Proposal: defaultdict
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Guido van Rossum wrote: > A bunch of Googlers were discussing the best way of doing the > following (a common idiom when maintaining a dict of lists of values > relating to a key, sometimes called a multimap): > > if key not in d: d[key] = [] > d[key].append(value) /.../ > Feedback? +1. check it in, already (as collections.defaultdict, perhaps?) alternatively, you could specialize even further: collections.multimap, which deals with list values only (that shallow copy thing feels a bit questionable, but all alternatives feel slightly overgeneralized...) </F>
- Previous message: [Python-Dev] Proposal: defaultdict
- Next message: [Python-Dev] Proposal: defaultdict
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list