passing by refference

Doug Quale quale1 at charter.net
Thu May 15 20:34:25 EDT 2003


"Fredrik Lundh" <fredrik at pythonware.com> writes:

> Doug Quale wrote:
> 
> > No, that's exactly what call-by-value means when applied to Python values
> > (actually r-values).  What happens when you try this:
> >
> > >>> y = [1, 2, 3]
> > >>> x = y
> > >>> x[:] = [-1]*3
> > >>> y
> > [-1, -1, -1]
> >
> > Same behavior, no function calls.
> 
> except that "x[:] =" *is* a method call.

It's special syntax.  It can be viewed as a special operator on the
surface level and it would behave the same.




More information about the Python-list mailing list