list vs tuple

Joshua Marshall jmarshal at mathworks.com
Sun Apr 1 17:55:06 EDT 2001


Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> wrote:
> 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.

Python does pass by value.  It's just that the "values" are references
to begin with.  In languages which pass by reference, assigning to the
formal parameter changes the caller's state.



More information about the Python-list mailing list