On May 3, 6:33 pm, Mel <mwil...@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). But that does not happen. The string is assigned to the list seen by the caller. Thus we can exclude call-by-value. The second proposition is correct. This allows us to exclude pass-by-reference similar to C++, Pascal and Fortran. Thus: def identify_call (a_list): a_list[0] = "If you cannot see this, you have call-by-value" a_list = ["If you can see this, you have call-by-reference"] Clearly Python has neither call-by-value nor call-by-reference. Python uses a third mechanism. Sturla -- http://mail.python.org/mailman/listinfo/python-list