anything like C++ references?

Terry Reedy tjreedy at udel.edu
Sun Jul 13 21:07:23 CEST 2003


"David McNab" <postmaster at 127.0.0.1> wrote in message
news:pan.2003.07.13.10.58.11.376531 at 127.0.0.1...
> In Python, basic types like strings and numbers are a weird
exception to
> the 'everything is an object' rule.

In Java perhaps, but NOT in Python.  This is WRONG, WRONG, WRONG.
Please do not muddy the waters like this.

In Python, most builtin types are immutable.  The two mutable builtin
types are lists and dicts.  Instances of user-defined classes are also
mutable by default.

>When you pass any other object in a function,
>But when you pass a string or numeric object, [incorrect statement
clipped]

In Python, everything is 'passed' to functions the same way:  first,
the argument expressions are evaluated one at a time, left to right.
In the typical case (number of argument expressions == number of
positional parameters), the resulting objects are then bound to the
corresponding parameter names, left to right, in the local namespace
of the function.  (Or, if you prefer, the names are bound ...)  The
type of the argument objects is not looked at.

How a particular interpreter performs name binding is its own
business, as long as the specified semantics are implemented.  What
CPython does may or may not be the same as Jython or any other actual
or potential computer implementation.  What any computer does is
probably significantly different from what human interpreters do.

Terry J. Reedy






More information about the Python-list mailing list