Trying to understand += better

n00m n00m at narod.ru
Mon Nov 23 00:11:31 EST 2009


> The first statement is creating a whole new list;

Yes but *imo* not quite exactly so.
We can't think of 2 lists as of absolutely independent
things.

... x = [[0]]
... id(x)
19330632
... id(x[0])
19316608
... z = x + [3]
... id(z)
19330312
... id(z[0])
19316608
...
... z[0] is x[0] # ?
True
... x[0][0] = 1
...
... z[0][0]
1



More information about the Python-list mailing list