Python one-liner?

Evan Driscoll edriscoll at wisc.edu
Fri Apr 13 23:44:21 EDT 2012


On 4/13/2012 22:42, Evan Driscoll wrote:
> Though I might as well ask another question... if I have a dict with
> values which are lists, what's a good way to say "append x to the list
> at key k, creating a list if it's not there"? dict.setdefault seems
> potentially promising but the docs are crappy and don't say how it works.
Ha ha, sorry I can't read right now apparently. dict.setdefault does
exactly what I wanted.

(The name just prompted another interpretation in my mind which doesn't
work and I got tunnel vision. I'll stop spamming now, and we return to
your regularly scheduled broadcast.)

Evan



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 552 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20120413/9c100308/attachment-0001.sig>


More information about the Python-list mailing list