2 ms·
Basically, but not quite. :-) The original result for b is: 0, (1, [...]), 2, 3] vs your version: [0, [...], 2, 3] The equivalent statements to the orig
by js2 8mo ago
Basically, but not quite. :-) The original result for b is:
0, (1, [...]), 2, 3]
vs your version:
[0, [...], 2, 3]
The equivalent statements to the original chained assignment are:
a, b = 1, [0, 1, 2, 3]
b[a] = 1, b # relies on cpython implementation detail¹
¹: Using 1 works because the integers -5 thru 256 are interned in cpython. Otherwise, or if you don't want to rely on an implementation detail, to be truly equivalent (i.e. `id(b[1][0]) == id(a)`), it's this:
a, b = 1, [0, 1, 2, 3]
b[a] = a, b