Dictionary of Dictionaries

bg_ie at yahoo.com bg_ie at yahoo.com
Mon Mar 5 11:22:24 CET 2007


Hi,

I have the following -

messagesReceived = dict.fromkeys(("one","two"), {})

messagesReceived['one']['123'] = 11111
messagesReceived['two']['121'] = 22222
messagesReceived['two']['124'] = 43333

This gives:

{'two': {'121': 22222, '123': 11111, '124': 43333}, 'one': {'121':
22222, '123': 11111, '124': 43333}}

but I expected -

{'one': {'121': 22222, }, 'two': {'123': 11111, '124': 43333}}

What am I doing wrong?

Thanks,

Barry.




More information about the Python-list mailing list