Deepcopy on nested referenced lists created by list multiplication does not work
问题 As much as I love Python, the reference and deepcopy stuff sometimes freaks me out. Why does deepcopy not work here: >>> import copy >>> a = 2*[2*[0]] >>> a [[0, 0], [0, 0]] >>> b = copy.deepcopy(a) >>> b[0][0] = 1 >>> b [[1, 0], [1, 0]] #should be: [[1, 0], [0, 1]] >>> I am using a numpy array as a workarround which I need later on anyway. But I really had hoped that if I used deepcopy I would not have to chase any unintended references any more. Are there any more traps where it does not