What is the correct way to initialize a bunch of variables to independent empty lists in Python 3?
>>> (a, b) = ([],)*2
>>> a.append([2,3])
>>> a
[[2, 3]]
>>> b
[[2, 3]]
>>> b.append([2,3,])
>>> b
[[2, 3], [2, 3]]
>>> a
[[2, 3], [2, 3]]
>>> (a, b) = ([] for _ in range(2))
>>> a.append([2,3])
>>> a
[[2, 3]]
>>> b
[]
>>> b.append([2])
>>> b
[[2]]
>>> a
[[2, 3]]
Why the first attempt does not allocate a
, b
independently in memory?