Message143793
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. |
|
Date |
User |
Action |
Args |
2011-09-09 19:29:04 | शंतनू | set | recipients:
+ शंतनू, docs@python |
2011-09-09 19:29:04 | शंतनू | set | messageid: <1315596544.14.0.783397700321.issue12951@psf.upfronthosting.co.za> |
2011-09-09 19:29:03 | शंतनू | link | issue12951 messages |
2011-09-09 19:29:03 | शंतनू | create | |
|