Hi everyone,

I have a problem with initialization.
>>> a, b = [[]]*2
>>> a.append(1)
>>> b
[1]

Why is this? Why does not this behave like the below:

>>> a, b = [[], []]
>>> a.append(1)
>>> b
[]

And, just to add to my confusion:

>>> [[]]*2
[[], []]
>>> [[], []] == [[]]*2
True

Thanks in advance for the explanation.
jbar


BTW, if it matters...
Python 2.4.1 (#2, Mar 30 2005, 20:41:35)
[GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to