All of the values in Python are really objects.
You can think of objects as bags that contain the value itself, with some more operations that you can use with the value (these are called methods).
We'll talk about object in more details in later posts.
Each object (i.e value) has:
A type (like int, str, float..etc)
An id (identifier, a long number like 140299920488592)
(if you are coming from languages like C or C++, then I'll say that these are not addresses in memory that you can use.)
In python, there are really no variables...
The word variable does appera in the documentation here and there, but you won't see a section devoted to variables.
Instead, the documentation
refers to names.
Docs say about names:
Names refer to objects.
So, names are what we call references that point to object (which are values).
Names are introduced by name binding operations.
So, to create a new name, you must immediatelly use it to refer to an object.
This is a visual representation of these ideas:
Immutability
Object in many types in Python cannot be changed.
Once created, they are immutable, and can only be destroyed when are not in use anymore.
Examples include int, float, str, tuple and others.
This is what really happens when you "change" the value of an integer:
myvar is pointing to an int object (value is 17), but this object cannot change its value!
When the python command instructs myvar to point at 41, the name must refer to a new object with this value.
Python may now remove the first object from memory, but it may still keep it in case the program needs the number 17 again. The interpreter re-use some numbers like this.
In any case, your program does not point to this number anymore.