Multi-dimensional list initialization trouble

Fredrik Lundh fredrik at pythonware.com
Thu May 25 17:32:13 EDT 2006


jonkje at gmail.com wrote:

> Hello I found this very strange; is it a bug, is it a "feature", am I
> being naughty or what?

the repeat operator (*) creates a new list with references to the same
inner objects, so you end up with a list containing multiple references 
to the same list.  also see:

     http://pyfaq.infogami.com/how-do-i-create-a-multidimensional-list

</F>




More information about the Python-list mailing list