Is this a bug in Python or something I do not understand.

Chris Rebert clp at
Thu Jan 1 22:00:25 CET 2009

On Thu, Jan 1, 2009 at 10:13 AM,  <davidalvi at> wrote:
> Consider these two lists comprehensions:
> L1=[[1 for j in range(3)] for i in range(3)]
> L2=[[1]*3]*3
> So far, everything is OK, but let us now modify the lists' contents in
> the following way:
> It seems a misbehaviour in Python, or there is something I do not
> understand in the syntax ????

The latter, and it's a FAQ. Please read
(it's question 4.6).


Follow the path of the Iguana...

More information about the Python-list mailing list