Objects in Python

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Aug 23 02:55:33 EDT 2012


On Wed, 22 Aug 2012 23:49:17 -0500, Evan Driscoll wrote:

> On 8/22/2012 18:58, Ben Finney wrote:
>> You haven't discovered anything about types; what you have discovered
>> is that Python name bindings are not variables.
>> 
>> In fact, Python doesn't have variables – not as C or Java programmers
>> would understand the term. What it has instead are references to
>> objects (with names as one kind of reference).
> 
> OK, I've seen this said a few times, and I have to ask: what do you mean
> by this? I consider myself pretty decent at Python and other languages,
> and I really don't get it.

I think the point that Ben would like to make is that while "name 
binding" is a specific kind of "variable", the word "variable" comes with 
too much baggage from the old-school C, Pascal etc. style of variables-
are-named-memory-locations. Most of the time, the differences are 
unimportant, but when they are important, if your mental image is that 
Python "variables" (name bindings) are like C or Pascal 
"variables" (memory locations), you're going to get confused.


[...]
> And many other languages have reference behavior and still call their
> bindings "variables", e.g. Scheme.

Yes, well in my opinion, a great deal of the terminology in use is 
absolutely dire. E.g. both Ruby and Java have the exact same parameter 
binding strategy as Python, only the Ruby people call theirs "call by 
reference" and the Java people call theirs "call by value", *both of 
which are identical*, and NEITHER of which are the same thing that C and 
Pascal programmers will understand by call by value *or* call by 
reference.

http://mail.python.org/pipermail/tutor/2010-December/080505.html



-- 
Steven



More information about the Python-list mailing list