a,b = b,a
Here, python interprets the comma separated variables as tuples. The RHS is first evaluated as a tuple and then stored in memory. The LHS is then evaluated as a tuple and is assigned the values of the RHS. Hence, the net effect is that the values of the variables are swapped.