Bugs item #1722956, was opened at 2007-05-21 12:21 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=1722956&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Parser/Compiler Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Jeff Britton (metal_one) Assigned to: Nobody/Anonymous (nobody) Summary: x = [[]]*2; x[0].append doesn't work Initial Comment: This bug is hard to explain in words. It is easiest to just look at the Interactive Python commands issued below. <x> is assigned a list of two empty lists, however there is something wrong with <x>. <y> is assigned a list of two empty lists using list comprehension. <y> is ok. A check of x == y, shows them equal. However, when trying to append [1,2] to x[0] both x[0] and x[1] are appended to. The same operation on <y> works correctly. >>> x = [[]]*2 >>> y = [[] for i in range(2)] >>> x == y True >>> x[0].append([1,2]) >>> x [[[1, 2]], [[1, 2]]] >>> y[0].append([1,2]) >>> y [[[1, 2]], []] I have tested with Python 2.5 and 2.4. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1722956&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com