[Python-Dev] chained assignment weirdity
Terry Reedy
tjreedy at udel.edu
Wed Nov 7 23:11:40 CET 2012
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.
What is weird -- to me ;-) -- is using side-effects in either example above.
--
Terry Jan Reedy
More information about the Python-Dev
mailing list