[Tutor] difference between [[], [], []] and 3*[[]]

Mitsuo Hashimoto hashimoto.m at gmail.com
Sat May 21 12:45:19 CEST 2005


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 the other hand,

>>> 3*[[]]
[[], [], []]

"[[], [], []]" is equal to  "3*[[]]" or not ?

After all, what should I do if I want to initialize a lot of lists ?
For example a = [], b = [], c = [],...., z = []

Thanks in advance,

Mitsuo


More information about the Tutor mailing list