For nested lists, I think a module should be used (copy.deepcopy(list)), as in:
>>> import copy
>>> a
[[5, 2, 3], [1, 2, 3], [1, 2, 3]]
>>> c = copy.deepcopy(a)
>>> c
[[5, 2, 3], [1, 2, 3], [1, 2, 3]]
>>> c[0][0] = 7
>>> c
[[7, 2, 3], [1, 2, 3], [1, 2, 3]]
>>> a
[[5, 2, 3], [1, 2, 3], [1, 2, 3]]
>>>
No comments:
Post a Comment