Sep-21-2017, 07:08 PM
Is this a nit? For example.
>>> y = 5
>>> id(y)
4297636480
>>> y = 7
>>> id(y)
4297636544
>>> x = 5
>>> id(x)
4297636480
>>>
Clearly the "stuff" on the right-hand side are objects and have a fixed location. The y and x are just labels that point to the objects.
Most books say that variables are like boxes stored somewhere by the compiler/assembler/loader and the items that appear on the right-hand side get placed in the appropriate box.
Is this a "so what?" not a big enough deal to mention? Can not teaching that ever hurt anything?
Seems simpler to think of variables as boxes rather than labels that get hung on (point to) objects.
Not sure of the best way to handle this.
Thx,
C
>>> y = 5
>>> id(y)
4297636480
>>> y = 7
>>> id(y)
4297636544
>>> x = 5
>>> id(x)
4297636480
>>>
Clearly the "stuff" on the right-hand side are objects and have a fixed location. The y and x are just labels that point to the objects.
Most books say that variables are like boxes stored somewhere by the compiler/assembler/loader and the items that appear on the right-hand side get placed in the appropriate box.
Is this a "so what?" not a big enough deal to mention? Can not teaching that ever hurt anything?
Seems simpler to think of variables as boxes rather than labels that get hung on (point to) objects.
Not sure of the best way to handle this.
Thx,
C