Message180522
I agree that this is somewhat surprising, but it is working as intended.
a = b = c
is equivalent to
a = c
b = c
except that the RHS is evaluated only once, which can be important.
You were either expecting it to be equivalent to
b = c
a = c
or expecting all of the LHS expressions to be evaluated before any assignments were done.
It could have been implemented any of these ways (though the last one is much more complex to implement). Python chose the first way.
There is a specific warning about this in the documentation, at the end of the section on assignment statements:
http://docs.python.org/3/reference/simple_stmts.html#assignment-statements |
|
Date |
User |
Action |
Args |
2013-01-24 13:46:42 | r.david.murray | set | recipients:
+ r.david.murray, benjamin.peterson, chupym |
2013-01-24 13:46:42 | r.david.murray | set | messageid: <1359035202.33.0.571079462263.issue17022@psf.upfronthosting.co.za> |
2013-01-24 13:46:42 | r.david.murray | link | issue17022 messages |
2013-01-24 13:46:41 | r.david.murray | create | |
|