floatref

Steven D'Aprano steve-REMOVE-THIS at cybersource.com.au
Wed Jul 14 00:31:54 EDT 2010


On Wed, 14 Jul 2010 03:19:36 +0200, Alf P. Steinbach /Usenet wrote:

> Gary Herron wrote:
>> Python does not have pointers, so if I take your wording"y.var and
>> x.var to point to the same value" literally, then the answer is NO
>> Python does not do that.
> 
> This is just a terminological issue. 

"Just"?

If people can't agree on terminology, they can't even understand each 
other, let alone communicate effectively. If I call you a fine fellow 
with a detailed grasp of programming and a helpful manner, but what I 
mean by "fine", "detailed" and "helpful" are different from what you mean 
by them, how can you tell if I've just complimented you or insulted you?

Gary did the right thing by pointing out that the simple-sounding term 
"points to" is anything but simple, it depends on what you mean by 
pointing and pointers.


> Saying "Python does not have
> pointers" is highly misleading in response to the OP's statement. It's
> easy enough to understand what he means. E.g., in the Java language
> specification "pointer" has a suitable meaning. 

And in a Java language forum, that would arguably be the right meaning to 
assume. Possibly even in a Jython forum. But this is neither, it's a 
Python forum, where "Python" is typically understood to be CPython, not 
Jython and certainly not Java, and "pointer" is typically understood to 
mean C or Pascal pointers.

In an English language forum, the correct meaning to use for "cafeteria" 
is a "dining hall", and not "fringe benefit" as it would be in a 
Hungarian forum. Likewise, the correct meaning to use for the word "gift" 
in an English forum is a present or object which is given, and not 
"poison" as a German might assume.


[...]
> You can't represent or usefully think of a C++ member pointer
> as a C or Pascal pointer. It isn't useful on its own. So, considering
> C++ and Java, the general pointer notion is something that refers,
> however obliquely. 

So an integer like 3 counts as a pointer, as you can use it as an index 
into a list, array or other sequence. In that sense, yes, Python has 
pointers, and makes frequent use of them. You can even do pointer 
arithmetic!

I don't think this position is terribly useful. It's possible to be *too* 
generic.


> You chose a specific meaning of "pointer" where the
> OP's statement does not make sense, but presumably the OP is explaining
> his needs in terms of a more general meaning of "pointer"; assuming
> anything else is silly.

The Zen of Python includes:

In the face of ambiguity, refuse the temptation to guess.

Wise words, not just for programming.




-- 
Steven



More information about the Python-list mailing list