Pass by reference or by value?
bdesth.quelquechose at free.quelquepart.fr
Sat Jul 14 06:46:06 CEST 2007
Robert Dailey a écrit :
> On Jul 13, 2:10 pm, Robert Dailey <rcdai... at gmail.com> wrote:
>>I noticed in Python all function parameters seem to be passed by
> I ran a few more tests and python actually does a pass by value,
Still wrong !-)
Python passes references to objects, but the *names* are local. So while
*mutating* (ie: calling a method that changes the state of) an object in
a function will impact the object outside the function, *rebinding* a
name will not impact the name outside the function.
But anyway, as Star mentionned, Ben Finney gave a pretty good (IMHO)
explanation in the nearby thread named "understanding python functions".
More information about the Python-list