[issue6219] nested list value change

Pushkar Paranjpe report at bugs.python.org
Sat Jun 6 09:04:03 CEST 2009


New submission from Pushkar Paranjpe <pushkarparanjpe at gmail.com>:

Is this a bug ?

>>> a = [[1,2],[3,4],[5,6]]
>>> a
[[1, 2], [3, 4], [5, 6]]
>>> b = a[0]
>>> b
[1, 2]
>>> b[0] = -8888
>>> b
[-8888, 2]
>>> a
[[-8888, 2], [3, 4], [5, 6]]
>>>

Created a new variable (b) which refers to an element in a list (a).
Changing the value of the new variable also reflects in the original
list. I thought the new variable is actually a new variable with its own
memory allocation and not a symbolic link to pre-existing data. is this
a bug?
Please help.

----------
components: Library (Lib)
messages: 88989
nosy: pushkarparanjpe
severity: normal
status: open
title: nested list value change
type: behavior
versions: Python 2.5, Python 2.6

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


More information about the Python-bugs-list mailing list