New submission from ughacks <ugha...@yahoo.com>: 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. ------- begin of code ------ total=[] for i in range(4): for j in range(i): root=[0,0,0,0] for k in [2,-2]: for l in [2,-2]: root[i]=k root[j]=l total.append(root) print root print total --------------- end of code ----- Result: each element is correctly generated [2, 2, 0, 0] [-2, 2, 0, 0] [2, -2, 0, 0] [-2, -2, 0, 0] [2, 0, 2, 0] [-2, 0, 2, 0] [2, 0, -2, 0] [-2, 0, -2, 0] [0, 2, 2, 0] [0, -2, 2, 0] [0, 2, -2, 0] [0, -2, -2, 0] [2, 0, 0, 2] [-2, 0, 0, 2] [2, 0, 0, -2] [-2, 0, 0, -2] [0, 2, 0, 2] [0, -2, 0, 2] [0, 2, 0, -2] [0, -2, 0, -2] [0, 0, 2, 2] [0, 0, -2, 2] [0, 0, 2, -2] [0, 0, -2, -2] But the total list is wrong [[-2, -2, 0, 0], [-2, -2, 0, 0], [-2, -2, 0, 0], [-2, -2, 0, 0], [-2, 0, -2, 0], [-2, 0, -2, 0], [-2, 0, -2, 0], [-2, 0, -2, 0], [0, -2, -2, 0], [0, -2, -2, 0], [0, -2, -2, 0], [0, -2, -2, 0], [-2, 0, 0, -2], [-2, 0, 0, -2], [-2, 0, 0, -2], [-2, 0, 0, -2], [0, -2, 0, -2], [0, -2, 0, -2], [0, -2, 0, -2], [0, -2, 0, -2], [0, 0, -2, -2], [0, 0, -2, -2], [0, 0, -2, -2], [0, 0, -2, -2]] ---------- messages: 100141 nosy: ughacks severity: normal status: open title: bug in s.append(x) type: compile error versions: Python 2.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue8023> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com