On 5 Mar, 11:45, "Amit Khemka" <[EMAIL PROTECTED]> wrote: > On 5 Mar 2007 02:22:24 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Hi, > > > I have the following - > > > messagesReceived = dict.fromkeys(("one","two"), {}) > > This will create a dictionary "messagesReceived", with all the keys > referring to *same instance* of the (empty) dictionary. > ( try: messagesReceived = dict( [(k,{}) for k in ('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}} > > And hence the results ! > > HTH, > > -- > ---- > Amit Khemka -- onyomo.com > Home Page:www.cse.iitd.ernet.in/~csd00377 > Endless the world's turn, endless the sun's Spinning, Endless the quest; > I turn again, back to my own beginning, And here, find rest.
Thanks for your help! -- http://mail.python.org/mailman/listinfo/python-list