[issue9982] Pointer problem in initializing array of arrays
Antoine Pitrou
report at bugs.python.org
Wed Sep 29 12:04:07 CEST 2010
Antoine Pitrou <pitrou at free.fr> added the comment:
That's expected behaviour, syntactically. Multiplying a sequence doesn't deep-copy its elements.
If you want an array of distinct arrays, just write:
>>> m1 = [[0,0,0,0] for i in range(4)]
>>> m1[1][0] = 6
>>> m1
[[0, 0, 0, 0], [6, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
----------
nosy: +pitrou
resolution: -> invalid
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9982>
_______________________________________
More information about the Python-bugs-list
mailing list