A class question

Hrvoje Niksic hniksic at xemacs.org
Mon Oct 29 10:43:57 EDT 2007


Bruno Desthuilliers <bruno.42.desthuilliers at wtf.websiteburo.oops.com>
writes:

> The problem is that your formulation implies (to me at least) that the
> variable is actually a kind of container for the object.

I really didn't expect it to be read that way, especially since the
sentence claims that the same instance can reside in several
variables.  If the term variable implied containment, that would not
be possible because different variables would imply different objects.

To be fair, the OP probably *did* confuse variables with containment,
and I rot13'ed my hack to avoid unnecessarily prolonging that
confusion.  However, I don't think his confusion is a consequence of
inaccurate terminology, but of an inaccurate mental model of Python
objects.  When the mental model is correct, the term "variable" works
as well as any other; when it's incorrect, using different words for
the same thing is of little help.

>>> Python's "variables" are name=>object bindings.
>>
>> No reason to use quotes. 
>
> Yes, there's one : to mark the difference between Python-like
> name=>object bindings and C-like labels-on-memory-address variables
> the latter model being the most commonly known to beginners.

Are you sure about the last part?  It seems to me that in recent times
more Python beginners come from a Java background than from a C one.
In any case, "variable" is a sufficiently general concept not to be
tied to a specific implementation.  That the concept of variable
differs among programming languages is for me not reason enough to
eschew it.



More information about the Python-list mailing list