Problem with assigning variables of type List

Abhishek Roy abhishek at ocf.berkeley.edu
Wed Aug 21 10:06:55 EDT 2002


Max M <maxm at mxm.dk> wrote in message news:<3D633B27.50702 at mxm.dk>...
[snip]
>  >>> def foo(lst):
>      lst.append(42)  <----- Has an effect on the actual arguments
> 
His point seems to be that inside the function you can't change the id
of the object that 'lst' points to, so in his words you can't change
the argument 'lst'. However you can mutate the object that the
argument points to, which is a different issue. By his interpretation
C is also "call by value", which seems consistent - but not how most
people put it.

Abhishek



More information about the Python-list mailing list