Dictionary of Dictionaries

Bart Ogryczak B.Ogryczak at gmail.com
Mon Mar 5 09:29:23 EST 2007


On Mar 5, 11:22 am, b... at yahoo.com wrote:
> messagesReceived = dict.fromkeys(("one","two"), {})

This creates two references to just *one* instance of empty
dictionary.
I'd do it like:
messagesReceived = dict([(key, {}) for key in ("one","two")])







More information about the Python-list mailing list