94 ms·
It’s assigned left to right, not right to left. It’s documented in the Python language reference. > An assignment statement evaluates the expression list and a
by kccqzy 9mo ago
It’s assigned left to right, not right to left. It’s documented in the Python language reference.
> An assignment statement evaluates the expression list and assigns the single resulting object to each of the target lists, from left to right.
Consider this:
a = [1, 2]
i = a[i] = 1
If assignment were to happen right to left, you would get a NameError exception because the first assignment would require an unbound variable.
- mathisfun123 9mo agoFine but that even moreso illustrates how goofy the expectation that the "ctor" for [] would be called twice.