scared about refrences...

Fredrik Lundh fredrik at pythonware.com
Wed Nov 1 15:34:52 EST 2006


SpreadTooThin wrote:

>> Plain wrong. There's no "primitives" (ie : primitive data types) in
>> Python, only objects. And they all get passed the same way.
> 
> so..
> def fn(x):
>    x = x + 1
>    print x
> 
> a = 2
> fn(a)
> fn(2)
> 
> Wouldn't you say that this is being passed by value rather than by
> refrence?

Python uses neither "call by value" nor "call by reference", but that's 
irrelevant: the result you're seeing has nothing to do with the calling 
model, but with how assignment works.  Gabriel already posted this link; 
I suggest you read it again:

     http://www.effbot.org/zone/python-objects.htm

</F>




More information about the Python-list mailing list