Can someone explain modifying vs. overwriting object reference in an easy to understand way? Here is an example of what I mean:
By modifying an object reference:
nested_list = [[]]*3
nested
result:
[[], [], []]
# now let me **modify** the object reference
nested[1].append('zzz')
result:
[['zzz'], ['zzz'], ['zzz']]
By overwriting an object reference:
nested_list = [[]]*3
nested
result:
[[], [], []]
# now let me **modify** the object reference
nested[1] = ['zzz']
result:
[[], ['zzz'], []]
Does that mean when using "append" we are only modifying the object reference while using assigning values i.e.
nested[1] = ['zzz']
we are overwriting the value and assigning nested[1] to a new object reference? Is it caused by the underlying difference between the "append" method and assigning values? If so what's the difference?