Steven D'Aprano wrote:
"By value" is very simple. It means a copy of the value is passed to the
function.
It only means that if you understand "copy" to mean
whatever it is that happens when you perform an assignment.
In Python, the term "copy" tends to imply rather more
than that, so you go off the rails using that definition.
So my recommendation is just to tell them that it works by assigning the
result of evaluating the actual parameter to the formal parameter.
That's not an explanation, it's obfuscation at its worst.
I didn't necessarily mean to use those exact words. The
essential point is that you explain parameter passing in
terms of assignment.
What *is* the
result of evaluating the actual parameter? Is it a reference to the
object or the object itself?
It doesn't matter! All that matters is that they understand
what happens when you assign it to a name. You can explain
that using whatever terminology you want, as long as they
end up with a mental model that works. Then you tell them
that passing a parameter is just like doing an assignment.
I can't think what could be simpler or less obfuscatory
than that.
If they understand how assignment works in Python, that tells them all
they need to know.
Nonsense.
Why? What else *do* you think they need to know?
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list