What other languages use the same data model as Python?
Michael Torrie
torriem at gmail.com
Wed May 4 11:40:02 EDT 2011
On 05/04/2011 08:44 AM, sturlamolden wrote:
> On May 3, 6:33 pm, Mel <mwil... at the-wire.com> wrote:
>
>> def identify_call (a_list):
>> a_list[0] = "If you can see this, you don't have call-by-value"
>> a_list = ["If you can see this, you have call-by-reference"]
>
>
> The first one is a mistake. If it were pass-by-value, it would
> assign the string to a list unseen by the caller -- i.e. a copy
> of the caller's argument (same value, different object).
> <snip>
> Clearly Python has neither call-by-value nor call-by-reference.
>
> Python uses a third mechanism.
Which is exactly what the code showed. The first one isn't a mistake.
You just read it wrong.
More information about the Python-list
mailing list