list vs tuple

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Sat Mar 31 14:23:15 EST 2001


Fri, 30 Mar 2001 15:25:14 -0500, Michael Prager <Mike.Prager at noaa.gov> pisze:

> To the naive user, the EFFECT is different.  If the object is
> immutable, the statement appears to act just like it does in
> many other languages.  (It may not really act that way, but the
> difference is hidden.)

Indeed. Python's behavior is perfectly consistent. The problem is that
for immutable types there is no difference between passing by value
and passing by reference, so a naive user might think that Python
passes by value. They don't realize that in this case there would
be no difference and that the same behavior could be also explained
differently.

> That behavior is not in agreement with the "mental model" used
> by many other languages,

But most languages treat = like Python. In some of them it does not
really matter because almost all values are immutable (functional
programming), in others it matters as in Python for mutable objects
(Lisp, Scheme, Eiffel, Java, C#, Ruby, Smalltalk).

C, C++, Pascal, Perl and some older languages that I don't know pass
by value by default. All the rest pass by reference.

-- 
 __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK



More information about the Python-list mailing list