Предположим, что у нас есть:
Код: Выделить всё
>>> x = 1
>>> y = 2
Код: Выделить всё
>>> x, y = y, x+y
>>> x
2
>>> y
3
Код: Выделить всё
>>> x = 1
>>> y = 2
>>> x = y
>>> y = x+y
>>> x
2
>>> y
4
See also Multiple assignment semantics regarding the effect and purpose of parentheses on the left-hand side of a multiple assignment.
See also Understand Python swapping: why is a, b = b, a not always equivalent to b, a = a, b? for more complex cases, where the order of assignment matters.
Источник: https://stackoverflow.com/questions/872 ... -in-python