[issue8023] bug in s.append(x)

2010-02-26 Thread Mark Dickinson
Mark Dickinson added the comment: > So s.append(x) just copies the pointer, not the actual value. Yes, that's a reasonable way to think about it (though the term 'reference' seems to more popular than 'pointer' in this context). It matches the implementation, too: internally, a list is repre

[issue8023] bug in s.append(x)

2010-02-26 Thread ughacks
ughacks added the comment: Thank you for kind explanation. So s.append(x) just copies the pointer, not the actual value. It is a little tricky to know that. -- ___ Python tracker _

[issue8023] bug in s.append(x)

2010-02-26 Thread Mark Dickinson
Mark Dickinson 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! [[

[issue8023] bug in s.append(x)

2010-02-26 Thread ughacks
New submission from ughacks : Dear, I am using $ python -V Python 2.6.4 on Ubuntu 9.10 I met a serious bug in s.append(x) operation. If I append a list into another list, there is a change of content. In the following code, [2,-2,0,0] is replaced with [-2,-2,0,0] after s.append(x) operaton.