But if lst[42]["pos"] happens to hold an integer value, then
lst[42]["pos"]
is ALREADY a reference to an integer value
a
is NOW a reference to the same integer value
will _copy_ that integer value into 'a', right? Changing 'a' will not
change the value at lst[42]["pos"]
No... "a" now references the same integer... But in Python you can
NOT change an integer. So an subsequent assignment to "a"
a = xyz
doesn't change the integer, it changes "a" to NOW references whatever
object "xyz" references.
Time for the Post-It note simile.
Classical languages use the "post office sorting box" view. Each box
(variable name) has a fixed address, that can not be changed.
a = xyz
means "look in the box 'xyz', make a copy of what is in there, and put
that copy in the box 'a' (removing anything that had been in box 'a')"
In Python, the boxes (variable names) don't have fixed addresses.
Instead, the names are "on Post-It notes".
a = xyz
means "find the Post-It with 'a' written on it; if not found, create a
new Post-It. MOVE that Post-It from where ever you found it, to the box
that has a Post-It with 'xyz' written on it. If the location you'd found
'a' has NO Post-It notes on it, garbage collect it"
Note that: the object (integer, whatever) is NOT attached to the
name, rather the name is attached to the object -- one object can have
many names (after the above example, the object has two names minimum
"a" and "xyz" are both stuck to the object). If you now do an assignment
to one of the names, /that/ name gets /moved/ to the new object.
--