By value or by reference?

JCM joshway_without_spam at myway.com
Mon Oct 18 14:21:35 EDT 2004


Josiah Carlson <jcarlson at uci.edu> wrote:

>> I've given up expressing my opinion on the matter.  Everyone here
>> seems to have a different notion of what "pass-by-reference" and
>> "pass-by-value" mean.  It's funny--I've never run into trouble with
>> these terms before seeing these discussions on C.L.Py.

> It is because Python does it differently from most other languages, and
> it doesn't fit the paradigms of "pass by value" or "pass by reference"
> as already explained by Alex Martelli.

It's really not that different.  It's very similar to the way Java
handles objects, and how scheme does argument-passing.

> Python does name binding with references.  That is, each reference is
> given a name, but you cannot change data by assigning to a name; you can
> only change what data that name points to.  There are certain operations
> that can be done with mutable objects and immutable objects, but that is
> another discussion entirely.

Yes.  These two issues often get muddled together in discussions about
argument passing.  Are you avoiding the term "variable"?  Some don't
like to use it because they see Python as somehow fundamentally
different than other languages.  I think the term fits nicely.

> There is not so much an argument, but there is a semantic "what the hell
> is it doing" that is not being communicated properly.  I am sure there
> is a FAQ about this, but I don't have the link handy, and I can't quite
> find the right incantation for Google.

>  - Josiah




More information about the Python-list mailing list