A
ast
hello
Consider following code:
True
I understand that there is a single object 7 somewhere in memory and
both variables A and B point toward this object 7
now do the same with a list:
It seems this time that there are 2 distincts objects [1, 2] in memory. l1 points
toward the first one and l2 points toward the second one.
if I change one, the second remains unchanged
I dont really understand why the behavior is different.
Both integer 7 and list [1, 2] are objects. Why is it
different ?
thanks
Consider following code:
True
I understand that there is a single object 7 somewhere in memory and
both variables A and B point toward this object 7
now do the same with a list:
Falsel1 = [1, 2]
l2 = [1, 2]
l1 is l2
It seems this time that there are 2 distincts objects [1, 2] in memory. l1 points
toward the first one and l2 points toward the second one.
if I change one, the second remains unchanged
[1, 2]l1.append(3)
l1 [1, 2, 3]
l2
I dont really understand why the behavior is different.
Both integer 7 and list [1, 2] are objects. Why is it
different ?
thanks