why does this happen? (messed up previous post)

Dan Parisien dan at eevolved.com
Sun Feb 11 18:22:49 EST 2001


Dan Parisien wrote:

> key = 0
> dict = {0:''}
> key = dict[key] = "__0"
> print key
> >>> __0
> print dict
> >>> {9: '', '__9': '__9'}
> 
> It doesn't do it from right to left like in c? Obviously not. Does anyone
> know why?
> 
> thank you,
> Dan
> 
> 
haha. I wrote the example, _then_ copied and pasted from a terminal. serves 
me right.

Sorry for the confusion.

key = "key"
dict = {"key":None}
key = dict[key] = "newval"

print key
>>> newval
print dict
>>> {"key":None, "newval":"newval"}

I was expecting
print dict
>>>{"key":"newval"}

I'm using Python 2.0.1

thank you,
Dan




More information about the Python-list mailing list