[ python-Bugs-1084906 ] list initialization bug

SourceForge.net noreply at sourceforge.net
Tue Dec 14 06:11:43 CET 2004


Bugs item #1084906, was opened at 2004-12-14 00:11
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1084906&group_id=5470

Category: Python Interpreter Core
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: py_py (pingpy)
Assigned to: Nobody/Anonymous (nobody)
Summary: list initialization bug

Initial Comment:
Python 2.3.4 running on Linux Redhat 9.1

The following initialization produces an unwanted (I
think) side effect,

a,b=2*[[0]*2]

It seems that both a and b point to the same address
For example,
a[1]=1
gives me
a=[0,1]
but produces, as a side effect,
b=[0,1] !!!!

However, the following works
a,b = [[0]*2,[0]*2]


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1084906&group_id=5470


More information about the Python-bugs-list mailing list