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 शंतनू
Recipients docs@python, शंतनू
Date 2011-09-09.19:29:03
SpamBayes Score 1.0021929e-06
Marked as misclassified No
Message-id <1315596544.14.0.783397700321.issue12951@psf.upfronthosting.co.za>
In-reply-to
Content
URL: http://docs.python.org/library/stdtypes.html

Following example is given.

>>> lists = [[]] * 3
>>> lists
[[], [], []]
>>> lists[0].append(3)
>>> lists
[[3], [3], [3]]


Behavior is as follows.

>>> a = [[]] * 3
>>> a
[[], [], []]
>>> a[0] = 1
>>> a
[1, [], []]
>>> 


Python interpreter details:

$ python
Python 2.7.2 (default, Aug 22 2011, 13:53:27) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
History
Date User Action Args
2011-09-09 19:29:04शंतनूsetrecipients: + शंतनू, docs@python
2011-09-09 19:29:04शंतनूsetmessageid: <1315596544.14.0.783397700321.issue12951@psf.upfronthosting.co.za>
2011-09-09 19:29:03शंतनूlinkissue12951 messages
2011-09-09 19:29:03शंतनूcreate