What are the steps that Python actually does to assign multiple variables at one line?
I use to do A[0], A[1] = A[1], A[0] to swap, but recently I got a bug when assigning a linked list.
# insert self->node->...
def insert_next(self, node):
node.next, node.prev = self.next, self
self.next, self.next.prev = node, node
self.next
become node
earlier than I expected, so the assign become
self.next, node.next = node, node
However, if I do
self.next.prev, self.next = node, node
It works!
I "assume" the steps are
1. cache values at the right side
2. assign to left side one by one, left to right
not
1. cache values at the right side
2. cache the ref at the left side
2. assign to ref one by one, left to right
So, what are the steps?