Finding the instance reference of an object

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Tue Oct 28 23:31:53 CET 2008


On Tue, 28 Oct 2008 09:59:57 -0600, Joe Strout wrote:

> There are only the two cases, which Greg quite succinctly and accurately
> described above.  One is by value, the other is by reference.  Python
> quite clearly uses by value.

That is absolute nonsense, based on the idiotic assumption that 
programmers should care more about an arbitrary reference to a value than 
to the value itself.

I'm sure I've quoted the excellent effbot before, but he deserves 
repeating:

[quote]
well, I guess you can, in theory, value an artificial number assigned
to an object as much as the object itself.

    "Joe, I think our son might be lost in the woods"
    "Don't worry, I have his social security number"
[end quote]

As I wrote yesterday:

The value of a Python name is the Python object assigned to it, not an 
arbitrary memory location that points to the object. Even you would 
consider it obfuscatory if I executed this code:

x = "Norwegian Blue"

and then insisted that the value of x was "3086179808L, but if I run that 
line of code again it could get another value, and naturally if you run 
it on your computer you're almost certain to get a different value".

By your definition of "value=reference", the above is perfectly correct, 
and utterly, completely pointless, useless and unhelpful. It's rather 
like listing the ingredients of a cake as "Atoms". Technically true, but 
missing the point.

Once we discard the unhelpful assumption that value=reference, your 
entire argument falls apart.



-- 
Steven



More information about the Python-list mailing list