stands2reason wrote:
Vectorspace wrote:
zacb wrote:
And variables are not actually variables?
In what respect?
I think he's referring to the fact that in Python, every variable actually an object reference, as opposed to in C, where every variable is a distinct block of memory. This means that "assignment" operations actually copy a pointer and give you two "variables" pointing to the same thing
Ah, OK, I was initially confused by that, because it's different for different kinds of data:
Code:
>>> a=1
>>> b=a
>>> a=2
>>> b
1
>>> foo=[1,2]
>>> bar=foo
>>> foo[1]=3
>>> bar
[1, 3]
OK, in fact, it's consistent. In the first case, "a" is just reassigned to something else, and nothing is modified. In the second case, the
content of "foo" is modified, and because "bar" points to the same data, this also means that the content of "bar" is modified.
But you in languages like Java, you have the same problem.