[Python-Dev] chained assignment weirdity
Ned Batchelder
ned at nedbatchelder.com
Thu Nov 8 02:11:21 CET 2012
On 11/7/2012 5:11 PM, Terry Reedy wrote:
> On 11/7/2012 4:39 PM, Ned Batchelder wrote:
>
>> Just to be clear: the reference guide says that the behavior *SHOULD BE*
>> (but is not yet) this:
>>
>> Python 3.3.0
>> >>> {print("a"):print("b")}
>> a
>> b
>> {None: None}
>> >>> d = {}
>> >>> d[print("a")] = print("b")
>> b
>> a
>> >>>
>>
>> Is this or is this not "weird" to you?
>
> Not weird. Expressions and assignment targets are each consistently
> evaluated left to right (except as *necessarily* alter by precedence),
> with expressions evaluated before targets.
>
Sorry, I should have been clearer: I was asking about weird not to say,
"This is weird and should be changed!", but to get clarification from
Serhiy about his statement, " It will be weird if a dict comprehension
and a plain loop will be inconsistent." I honestly didn't know which
behavior he considered inconsistent and therefore weird.
--Ned.
More information about the Python-Dev
mailing list