On Sun, Nov 20, 2016 at 10:47 PM, Bev in TX <[email protected]> wrote:
> From the Python 3.5.2 docs:
>
> 6.15. Evaluation order
> Python evaluates expressions from left to right. Notice that while
> evaluating an assignment, the right-hand side is evaluated before the
> left-hand side.
>
> Thus, spam = eggs = cheese = obj is equivalent to:
>
> spam = (eggs = (cheese = obj))
Except that that's not how it's parsed. Assignment in Python isn't an
operator. You cannot run the parenthesized version:
>>> spam = (eggs = (cheese = obj))
File "<stdin>", line 1
spam = (eggs = (cheese = obj))
^
SyntaxError: invalid syntax
Chained assignment is a special piece of syntax.
https://docs.python.org/3/reference/simple_stmts.html#assignment-statements
You're not evaluating one assignment and then another; it's a single
assignment statement that has a target_list. Scroll down a little in
that page and you'll see an example that specifically points this out.
ChrisA
--
https://mail.python.org/mailman/listinfo/python-list