Variables vs. names
Aahz
aahz at pythoncraft.com
Sun Oct 6 16:58:03 EDT 2002
In article <3D7F8132.2D5CEC24 at earthlink.net>,
Joseph A. Knapka <jknapka at earthlink.net> wrote:
>
>I understand that a Python "variable" is really just a dictionary key;
>fine. In other languages, instead of "naming" a dictionary entry, a
>variable might directly "name" a chunk of storage. So other than the
>layer of indirection introduced by the dictionary mapping, what is
>the practical significance of "names bound to values" vs "variables
>with values"? Are there languages that achieve Python's semantics
>using "real" variables? Java's semantics seem pretty much identical to
>Python's in this respect, yet nobody in the Java community will object
>if you call a thing-with-a-name-and-a-value a "variable".
Python names don't have values. Names are always references to objects.
I don't know Java well enough to have any clue how it handles references,
but I know Java doesn't have pointers. Michael Hudson has claimed that
Common Lisp "places" are similar to Python names, but I don't know Common
Lisp at all, and I haven't yet had enough discussion with Michael to
verify that places have the same semantics.
Python immutables allow easy glossing over of the special semantics, but
mutables are another story:
a = []
b = a
a.append('foo')
print b
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
Project Vote Smart: http://www.vote-smart.org/
More information about the Python-list
mailing list