New submission from शंतनू <shanta...@gmail.com>:

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.

----------
assignee: docs@python
components: Documentation
messages: 143793
nosy: docs@python, शंतनू
priority: normal
severity: normal
status: open
title: List behavior is different
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12951>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to