[New-bugs-announce] [issue9982] Pointer problem in initializing array of arrays

Marvin Mundry report at bugs.python.org
Wed Sep 29 10:40:27 CEST 2010


New submission from Marvin Mundry <marvin.mun at gmx.de>:

>>> m1=[[0,0,0,0]]*4
>>> m1
[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
>>> m1[0][0]+=1
>>> m1
[[1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0]]

after initializing an array of arrays as done in the first line of the code snippet all elements in the array point to the same object in memory.

----------
components: None
messages: 117581
nosy: mastermarv
priority: normal
severity: normal
status: open
title: Pointer problem in initializing array of arrays
versions: Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9982>
_______________________________________


More information about the New-bugs-announce mailing list