[New-bugs-announce] [issue46145] List reference not working properly

Antara report at bugs.python.org
Tue Dec 21 12:24:45 EST 2021


New submission from Antara <antara.data at gmail.com>:

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?

----------
messages: 408998
nosy: antarab
priority: normal
severity: normal
status: open
title: List reference not working properly
type: behavior

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46145>
_______________________________________


More information about the New-bugs-announce mailing list