R. David Murray added the comment:

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

----------
nosy: +r.david.murray
resolution:  -> invalid
stage:  -> committed/rejected
status: open -> closed
title: Inline assignation uses the newly created object -> Inline assignment 
uses the newly created object
type:  -> behavior

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17022>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to