[EMAIL PROTECTED] wrote:
> Hello I found this very strange; is it a bug, is it a "feature", am I
> being naughty or what?
> 
>>>> foo = [[0, 0], [0, 0]]
>>>> baz = [ [0]*2 ] * 2
>...
> Why on earth does foo and baz behave differently??

This is a frequently made mistake.
try also:
 >>> bumble = [[0]*2 for 0 in xrange(2)]

Think hard about why that might be.
Then try:

 >>> [id(x) for x in foo]
 >>> [id(x) for x in baz]
 >>> [id(x) for x in bumble]

Now check your upper scalp for lightbulbs.

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to