A class question

Hrvoje Niksic hniksic at xemacs.org
Mon Oct 29 07:53:12 EDT 2007


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

>> As others have answered, an instance can live in many variables,
>
> "be bound to many names" would be more accurate IMHO.

Technically more accurate maybe (but see below), but I was responding
to a beginner's post, so I was striving for ease of understanding.

> Python's "variables" are name=>object bindings.

No reason to use quotes.  Variable is just as acceptable a term, one
used by Python itself, as witnessed by the "vars" builtin, but also in
PEP 8, in the language reference, and elsewhere in the docs.  Even the
quite technical language reference uses both terms, such as in this
paragraph under "Naming and binding":

    If a name is bound in a block, it is a local variable of that
    block. If a name is bound at the module level, it is a global
    variable. (The variables of the module code block are local and
    global.) If a variable is used in a code block but not defined
    there, it is a free variable.

I disagree with the idea that the terms "name" and "binding" are the
only correct terminology.  Python is not the first language to offer
pass-by-object-reference assignment semantics.  It shares it with
Lisp, Java, and many others, none of which have problems with the term
"variable".



More information about the Python-list mailing list