Bugs item #1084906, was opened at 2004-12-14 00:11 Message generated for change (Comment added) made by rhettinger 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: Closed >Resolution: Invalid 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] ---------------------------------------------------------------------- >Comment By: Raymond Hettinger (rhettinger) Date: 2004-12-14 02:01 Message: Logged In: YES user_id=80475 Thanks for the report; however, this is correct behavior. Learning about shallow vcrsus deep copies is a key to understanding the language. Start by reading the FAQ: http://www.python.org/doc/faq/programming.html#how-do-i-create-a-multidimensional-list ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1084906&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com