[Python-Dev] dict.addlist()
Bob Ippolito
bob at redivi.com
Tue Jan 20 09:26:39 EST 2004
On Jan 20, 2004, at 9:17 AM, Raymond Hettinger wrote:
> Here is anidea to kick around:
>
> Evolve and eventually replace dict.setdefault with a more specialized
> method that is clearer, cleaner, easier to use, and faster.
>
> d.addlist(k, v) would work like d.setdefault(k,
> []).append(v)
-1
There are other reasons to use setdefault. This one is pretty common
though, but I think a more generic solution could be implemented.
Perhaps:
d.setdefault(k, factory=list).append(v) ?
-bob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2357 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-dev/attachments/20040120/09595ead/smime.bin
More information about the Python-Dev
mailing list