Problem with assigning variables of type List

Peter Hansen peter at engcorp.com
Wed Aug 21 00:47:15 CEST 2002


Fredrik Lundh wrote:
> 
> Peter Hansen wrote:
> 
> > > if it were passed by reference, you'd see [42] on the last line.
> >
> > Nope.  Assignment works by rebinding the name to something else,
> > in effect changing the reference.  There is no pass by value in
> > Python.  (Although somebody may still refute this successfully,
> > but I don't think you have so far.)
> 
> To quote a more enlightened new zealander:
> 
>     ... you have to say something like "the object referred to
>     by x is passed by reference". Or alternatively, "x is passed
>     by value, and that value is a reference to an object". Just
>     calling it "pass by reference" or "pass by value" are both
>     half true and half false.

Thank you for _successfully_ and very clearly refuting my deliberately
provocative statements.  It seems to me that the simple terms 
"call by reference" and "call by value" are inadequate to explain 
what Python does, unless you always prefix them with "practically"
or "technically", respectively.

"Call by value, where the value passed is always a reference to
an object" covers it adequately for me.  It seems one can refer to
this effectively with the "call by object" from the quotes Donn Cave 
kindly provided in his post.

-Peter



More information about the Python-list mailing list