[docs] LIST PROBLEM IN PYTHON 3.3

Mike Bellamy mike.clare.bellamy at gmail.com
Sun Feb 21 00:34:13 EST 2016


I do not know whether to call this a BUG because it seems obviously
intended.. but totally undocumented and unexpected..

I am new to Python and this was a major problem, waste of time and gave
logic errors which were difficult to trace..

mylist = [[1,2],[3,4],[5,6],[7,8]]    # matrix or list of lists
temp = mylist[0]
mylist[3] = temp
print(mylist)

[1,2], [3,4], [5,6], [1,2]

# Now modify mylist[3]

mylist[3][1] = 0
print(mylist)

[1,0],[3,4],[5,6],[1,0]

Note mylist[0] and mylist[3] are pointers to the same data so when I
thought I was copying a list item Python did not make a true copy..
Nothing in the docs I read said anything about this..

regards
*Mike Bellamy*
*Keep Calm and Carry On*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20160221/d08a45e2/attachment.html>


More information about the docs mailing list