Modifying Class Object

Alf P. Steinbach alfps at start.no
Tue Feb 9 05:01:16 CET 2010


* Stephen Hansen -> Alf P. Steinbach:
>
> [snip]
> To say, "pass by value" implies things to people. It describes a sort of 
> world where I'm a function about to do some work, and on my desk I have 
> a series of boxes with names on it. It describes an environment where 
> someone comes over and drops something into each of my boxes. The 
> contents of these boxes are mine alone!

Then, when the imprecision makes people misunderstand, one should not say that.

One should then be more precise.

One should say /what/ is passed by value.


[snip]

>  >>> import copy
>  >>> def doit(a):
> ...     a += a
> ...     return a
> ... 
>  >>> test1 = 1
>  >>> test2 = doit(test1)
>  >>> test1
> 1
>  >>> test2
> 2
>  >>> test3 = [1]
>  >>> test4 = doit(test3)
>  >>> test3
> [1, 1]
>  >>> test4
> [1, 1]
> 
> I know you already know this, but the point is: you're -hurting- other 
> peoples understanding by using terms like this that don't apply to 
> Python's specific nature.

The terms apply very well to Java. And Java has the identical parameter passing 
mechanism for class type objects. Hence, the argument is bogus.


Cheers & hth.,

- Alf

PS: I cannot see any of your postings on Usenet. So I just sort of grabbed this 
from GMane and posted to Usenet. Hopefully you'll see it back at the list. :-)



More information about the Python-list mailing list