Pass by reference or by value?
rcdailey at gmail.com
Fri Jul 13 21:22:43 CEST 2007
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
> reference. This means that when I modify the value of a variable of a
> function, the value of the variable externally from the function is
> also modified.
> Sometimes I wish to work with "copies", in that when I pass in an
> integer variable into a function, I want the function to be modifying
> a COPY, not the reference. Is this possible?
I ran a few more tests and python actually does a pass by value,
meaning that a "copy" is made and the external variable that was
passed in remains unchanged. I actually want to know how to "pass by
reference", in that any changes made to a parameter inside of a
function also changes the variable passed in.
More information about the Python-list