This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: List reference not working properly
Type: behavior Stage: resolved
Components: Versions:
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: antarab
Priority: normal Keywords:

Created on 2021-12-21 17:24 by antarab, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg408998 - (view) Author: Antara (antarab) Date: 2021-12-21 17:24
o= [1,2,3,3]
print('o:',id(o))
d= o
print('d:',id(d))
d= [1,2,3,4]
dd= o
print('dd:',id(dd))
dd[3]= 5

print('o:',o)
print('d:',d)
print('dd:',dd)

=======================
Output:
o: 1976210449032
d: 1976210449032
dd: 1976210449032
o: [1, 2, 3, 5]
d: [1, 2, 3, 4]
dd: [1, 2, 3, 5]

Though o,d and dd points to the same memory pointer but d has different value. How can same memory location points to 2 different values?
msg408999 - (view) Author: Antara (antarab) Date: 2021-12-21 17:46
Not an issue
History
Date User Action Args
2022-04-11 14:59:53adminsetgithub: 90303
2021-12-21 17:46:47antarabsetstatus: open -> closed

messages: + msg408999
stage: resolved
2021-12-21 17:24:44antarabcreate