Multiple assignment and evaluation order in Python
In an assignment statement, the right-hand side is always evaluated fully before doing the actual setting of variables. So, x, y = y, x + y evaluates y (let’s call the result ham), evaluates x + y (call that spam), then sets x to ham and y to spam. I.e., it’s like ham = y … Read more