[Python-bugs-list] [ python-Bugs-580073 ] list append inconsistency

noreply@sourceforge.net noreply@sourceforge.net
Thu, 11 Jul 2002 06:19:28 -0700


Bugs item #580073, was opened at 2002-07-11 13:01
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=580073&group_id=5470

Category: Python Interpreter Core
Group: Python 2.2
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Simon Duane (sduane)
>Assigned to: Michael Hudson (mwh)
Summary: list append inconsistency

Initial Comment:
I get inconsistent behaviour of the list append method 
applied to a list of lists, depending on how the list of 
lists is initialised. Something like

a = [[], []]
a[0].append(1)

is ok, but

a=[[]]*2
a[0].append(1)

works incorrectly, for me at least, producing
[[1], [1]]
instead of
[[1], []]

Simon Duane

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

>Comment By: Michael Hudson (mwh)
Date: 2002-07-11 13:19

Message:
Logged In: YES 
user_id=6656

This is not a bug.

You might want to read this page:

    http://starship.python.net/crew/mwh/hacks/objectthink.html

to get a better idea how of objects work in Python.

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

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