Complex Nested Dictionaries

Irmen de Jong irmen at -NOSPAM-REMOVETHIS-xs4all.nl
Sun Feb 22 01:36:25 CET 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