[Chicago] I don't get why this works

Kyle Cronan kyle at pbx.org
Tue Apr 2 05:46:42 CEST 2013


Nah it's a['a'] = 'b' followed by a[a['a']] = 'b'

-Kyle


On Mon, Apr 1, 2013 at 10:41 PM, Brantley Harris <deadwisdom at gmail.com>wrote:

> Okay, then it should be a key error:
>
> > a['a'] = a[a['a']]
> KeyError: 'a'
>
>
> On Mon, Apr 1, 2013 at 10:25 PM, Alex Gaynor <alex.gaynor at gmail.com>wrote:
>
>> The assignments are going left to right.
>>
>> Alex
>>
>>
>> On Mon, Apr 1, 2013 at 8:24 PM, Brantley Harris <deadwisdom at gmail.com>wrote:
>>
>>> > a = {}
>>> > a['a'] = a[a['a']] = 'b'
>>> {'a': 'b', 'b': 'b'}
>>>
>>> What the what?  I would think that should KeyError, but it runs fine.
>>>  Someone splain.
>>>
>>> _______________________________________________
>>> Chicago mailing list
>>> Chicago at python.org
>>> http://mail.python.org/mailman/listinfo/chicago
>>>
>>>
>>
>>
>> --
>> "I disapprove of what you say, but I will defend to the death your right
>> to say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
>> "The people's good is the highest law." -- Cicero
>>
>> _______________________________________________
>> Chicago mailing list
>> Chicago at python.org
>> http://mail.python.org/mailman/listinfo/chicago
>>
>>
>
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20130401/e3d9c7b3/attachment.html>


More information about the Chicago mailing list