On 23/08/2012 09:59, Jussi Piitulainen wrote:
Steven D'Aprano writes:
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.

I don't get it either. To me the python-has-no-variables campaigners
seem confused. As far as I can see, Python can be seen in terms of
variables bound to (locations containing) values perfectly well, in a
way that should be quite familiar to people who come from Java (or
Lisp, Scheme like me).

[snip]
In Java a variable exists even when it has not been assigned a value.
In Python, on the other hand, the basic model is that a 'variable'
doesn't exist until it has been bound to an value (although, for
efficiency reasons, that's not entirely true, because at compile time
CPython will identify the local variables in a function and allocate a
'slot' for it).

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to