Problem with assigning variables of type List

Max M maxm at
Mon Aug 19 10:11:19 EDT 2002

> abhishek at (Abhishek Roy) writes:

>>      It appears that, 
>>a = b = []
>>is not the same as

I the first example a and b both point to the same list. In the second 
they are pointing to different lists.

A corresponding example with numbers would be:

a = b = 1
a = 1
b = 2

List and other complex objects are passe via reference and not by value 
for performance reasons.

regards Max M

More information about the Python-list mailing list