Variables vs. names
Martin v. Löwis
loewis at informatik.hu-berlin.de
Mon Oct 7 07:44:59 CEST 2002
aahz at pythoncraft.com (Aahz) writes:
> 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.
Python and Java are really the same in this respect. In Java,
variables are (normally) references to objects. The only exception are
primitive types, which are stored and passed by value. Since they are
immutable, this difference is negligible. Like Java, Python does not
have pointers, either.
I believe newcomers to Java have the same problem that they have in
Python: "If parameters are passed by reference, how come I cannot
modify a variable in the caller?" is a question that I've heard both
for Java and for Python.
More information about the Python-list