call-by-reference (was Re: Any other Python flaws?)

jcm grumble at
Fri Jun 15 23:02:11 CEST 2001

Martijn Faassen <m.faassen at> wrote:
> jcm <grumble at> wrote:

>> In my experience, there's good agreement about what call-by-reference
>> means just about everywhere but in newsgroups.  Python supports only
>> call-by-value -- you can't change the value of a variable in your
>> caller's scope (globals aside).

> Um, I wouldn't say it that way. Python supports changing the value a
> name references just fine:

> def foo(a):
>    a.append(42)

> l = [1, 2, 3]
> foo(l)

Note I said you can't change the value of a _variable_ in your
caller's scope.  Changing the state of an object isn't the same.

More information about the Python-list mailing list