This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ughacks
Recipients ughacks
Date 2010-02-26.08:55:30
SpamBayes Score 3.2144925e-08
Marked as misclassified No
Message-id <1267174532.93.0.564850423841.issue8023@psf.upfronthosting.co.za>
In-reply-to
Content
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]]
History
Date User Action Args
2010-02-26 08:55:33ughackssetrecipients: + ughacks
2010-02-26 08:55:32ughackssetmessageid: <1267174532.93.0.564850423841.issue8023@psf.upfronthosting.co.za>
2010-02-26 08:55:31ughackslinkissue8023 messages
2010-02-26 08:55:30ughackscreate