Complex Nested Dictionaries

Irmen de Jong irmen at -NOSPAM-REMOVETHIS-xs4all.nl
Sat Feb 21 19:36:25 EST 2004


T. Earle wrote:

> "if list a[key] exists, then append; otherwise, create a new list"

when a is a dict, key the required key, and object the value you want
to insert;

  a.setdefault(key,[]).append(object)

--Irmen



More information about the Python-list mailing list