This is not a Python vs Other Languages distinction - it's actually Value Types vs Reference Types distinction. Python uses reference types, and while many modern languages also tend to use reference types, it's common to compare Python(or any language, actually) to C/C++, which use value types.
(I'm simplifying things a lot here - there are languages that support both reference and value types, languages that use value types usually have pointers, which are the value-type version of reference types, and some languages that use reference types use value types for primitives)
With reference types - like what Python uses - the variable refers to the "box" in the memory. This means that multiple variables may refer to the same box:
class Foo:
x = 1
foo = Foo()
bar = foo
bar.x = 10
print(foo.x) # prints 10
When we changed bar.x
, foo.x
was changed as well. This is because foo
and bar
are both labels to the same box.
Compare with this C code:
#include<stdio.h>
struct Foo {
int x;
};
int main(int ARGC, char** ARGV) {
struct Foo foo, bar;
foo.x = 0;
bar = foo;
bar.x = 10;
printf("%d\n", foo.x); // prints 0
return 0;
}
C uses value types, so foo
and bar
are not "labels" - they are the boxes themselves. That's why when we change bar.x
, foo.x
does not change - they are different boxes, and bar = foo
does not make bar
refer to the same box as foo
like it did in Python - instead, it copies the content of the foo
box into the bar
box.
A
and hold values such as 1, 2, 3... depending what you store into it. A Python variable can also be calledA
and hold 1, 2, 3... depending what you store into it. Does your text really make that distinction between Python and all other languages?