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 ohwphil
Recipients ohwphil
Date 2021-09-11.02:55:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1631328907.83.0.354100007036.issue45169@roundup.psfhosted.org>
In-reply-to
Content
If you do the following:

lists=[[]]*100
lists[1].append('text')
print(lists[2])

you can see lists[2] contains 'text' even though it was appended to lists[1] in the text. A little more investigation with the id() function can show that the lists are shallowly copied when list multiplication occurs. I think this can confuse users when they try to use list multiplication to create nested lists, as they expected a deep copy to occur.
History
Date User Action Args
2021-09-11 02:55:07ohwphilsetrecipients: + ohwphil
2021-09-11 02:55:07ohwphilsetmessageid: <1631328907.83.0.354100007036.issue45169@roundup.psfhosted.org>
2021-09-11 02:55:07ohwphillinkissue45169 messages
2021-09-11 02:55:07ohwphilcreate