Hi I'm new to Python and I would like to know how he deals with memory
space.
I thought I had understood but I made a test and the results were
uncoherenent with my understanding, here is the thing:

>>> a=[1,2]
>>> l=[a,a]
>>> id(a); id(l[0]); id(l[1]);
61659528
61659528
61659528
>>> #All Have the same ID
>>> l[0]=[0,0]
>>> l
[[0, 0], [1, 2]]
>>> #Why didn't l[1] change as well?
>>> id(a); id(l[0]); id(l[1]);
61659528
61390280
61659528
>>> #How come id(l[0]) changed?
>>> a = [4,4]
>>> l
[[0, 0], [1, 2]]
>>> #Why didn't l[1] change? l[1] and a were occupying the same memory
adress!


Thank you for answering :)
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to