the trick is:
IPython prompt:
In [1]: A = [ [] ] * 2
In [2]: A
Out[2]: [[], []]
In [3]: A[0].append(1)
In [4]: A
Out[4]: [[1], [1]]
Obvious, it's not my expected result, what's I want is [[1], []]
. So why? I found no ref in the docs about python multiply sequence.
And is there any elegant(use no any explicit loop) ways to do that?