Pass by reference or by value?

Erik Max Francis max at alcyone.com
Sat Jul 14 00:26:13 CEST 2007


James Stroud wrote:

> Robert Dailey 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?
> 
> Not only is this possible, that is actually what happens with ints!

But that's because ints are immutable, not because there is an explicit 
copy of anything being made.

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
  San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis
   Ipsa scientia potestas est. "Knowledge itself is power."
    -- a Latin proverb



More information about the Python-list mailing list