Simultaneous assignment semantics in Python
问题 Consider the following Python 3 code: a = [-1,-1,-1] i = 0 And now consider the following two versions of a simultaneous assignment over both a and i: Assignment version 1: a[i],i = i,i+1 Assignment version 2: i,a[i] = i+1,i I would expect these two versions of simultaneous assignments to be semantically equivalent. However, if you check the values of a and i after each one of the simultaneous assignments, you get different states: Output for print(a,i) after assignment version 1: [0, -1, -1]