2005/5/21, Kent Johnson <[EMAIL PROTECTED]>:
> 3*[[]] makes a list with three references to the *same* list. This can cause
> surprising behavior:
>
> >>> l=3*[[]]
> >>> l
> [[], [], []]
> >>> l[0].append(1)
> >>> l
> [[1], [1], [1]]
I see.
> Often using a dict is a good solution to thi
Hello,
What's the difference between "[[], [], []]" and "3*[[]]" ?
>>> a,b,c = [[], [], []]
>>> id(a)
20609520
>>> id(b)
20722000
>>> id(c)
20721712
These ID is mutually different. But,
>>> a,b,c = 3*[[]]
>>> id(a)
20455728
>>> id(b)
20455728
>>> id(c)
20455728
>>>
These are the same.
On th