I just discovered in the definition of variables in Python. Namely:
a = b = 0
a = 1
gives me a=1
and b=0
or a and b are two independent variables.
But:
a = b = []
a.append(0)
gives me a = [0]
and b = [0]
, or a and b are two references to the same object. This is confusing to me, how are these two cases different? Is it because int
are primitive types or because lists are just pointers?