Problem with assigning variables of type List
see at below
Wed Aug 21 02:20:36 CEST 2002
On Tue, 20 Aug 2002 16:41:01 GMT, Fredrik Lundh wrote:
> Peter Hansen wrote:
>> > if it were passed by reference, you'd see  on the last line.
>> Nope. Assignment works by rebinding the name to something else,
>> in effect changing the reference. There is no pass by value in
>> Python. (Although somebody may still refute this successfully,
>> but I don't think you have so far.)
> Paul uses his own dictionary of computing terms, and can thus
> prove or refute anything he wants.
Wrong. It's you who have your own dictionary.
>> Maybe the issue is that these conventional terms do not apply
>> to Python as well as they do to more conventional languages...
> The conventional terms work just fine for Python, if you use them
> in the conventional way (e.g. see FOLDOC). I'm sure Paul knows
Fine, let's see what FOLDOC has to say, shall we? :-
(CBV) An evaluation strategy where arguments are evaluated before
the function or procedure is entered. Only the values of the
arguments are passed and changes to the arguments within the called
procedure have no effect on the actual arguments as seen by the
caller. See applicative order reduction, call-by-value-result,
strict evaluation, call-by-name, lazy evaluation.
So: arguments are evaluated before the function or procedure is
entered? Yup, Python does that. Only the values are passed, and
changes to the arguments within the called procedure have no effect on
the actual arguments as seen by the caller? Right again. Python
meets that definition. I guess it's call-by-value (what a surprise!)
An argument passing convention where the address of an argument
variable is passed to a function or procedure, as opposed to where
the value of the argument expression is passed. Execution of the
function or procedure may have side-effects on the actual argument
as seen by the caller. The C language's "&" (address of) and "*"
(dereference) operators allow the programmer to code explicit
call-by-reference. Other languages provide special syntax to declare
reference arguments (e.g. ALGOL 60). See also call-by-name,
So, the address of the argument variable is passed? Not in Python.
Execution of the function or procedure may have side-effects on the
actual argument as seen by the caller? Not in Python. Python fails
to meet this definition. I guess it's not call-by-reference
(surprises everywhere you look, today!)
Yes, the conventional terms work just fine for Python, if you use them
in the conventional way. And if you do that, it's call by value.
Time to revise your personal dictionary, Fredrik?!
> (Paul uses the term "value" to mean what most other people, in-
> cluding FOLDOC, would call a "reference".
 The variable contains an address, and that address is passed to
the function; that's not at all the same thing as passing the address
of the variable.
Just because we Lisp programmers are better than everyone else is no
excuse for us to be arrogant. -- Erann Gat
(concatenate 'string "Paul Foley " "<mycroft" '(#\@) "actrix.gen.nz>"))
More information about the Python-list