I have some experience in C, and having some trouble understanding Python's way of handling names (identifiers). As I understand it, declaring a list x = [1, 2]
and then declaring a new label y = x
, I seem to be actually making x
as the pointer, and y
, also a pointer, holds the same address as x. But in Python we are calling this labeling (these are different concepts?).
The same system happens with: x = 5
and y = x
. Where x
is now a label for an integer, 5
, and y
is a label for 5
as well. But now when I change x
it turns out y
will not change. So in the latter case, I do not think x
or y
are pointers in that sense. Are x
and y
on the stack as opposed to the heap? If so, how do I know which one they are? Is applying knowledge of the stack and heap useless in this situation, perhaps even detrimental? I am really confused about this part of the language, thank you for helping.