[issue8023] bug in s.append(x)
Mark Dickinson
report at bugs.python.org
Fri Feb 26 10:18:22 CET 2010
Mark Dickinson <dickinsm at gmail.com> added the comment:
This is a bug in your code, rather than in Python.
A simpler example, for the purposes of explanation:
>>> root, total = [0], []
>>> total.append(root)
>>> total # good so far
[[0]]
>>> root[0] = 1 # modify root
>>> total # note that total changes here!
[[1]]
>>> total.append(root)
>>> total
[[1], [1]]
In effect, total contains two references to the same list. Modify that list, and you'll see those changes reflected in `total` as well.
----------
nosy: +mark.dickinson
resolution: -> invalid
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8023>
_______________________________________
More information about the Python-bugs-list
mailing list