Python variables?

Ben Finney ben+python at benfinney.id.au
Mon Sep 30 18:37:01 EDT 2013


Ethan Furman <ethan at stoneleaf.us> writes:

> From [Ned Batchelder]'s blog:

> > Names are Python's variables: they refer to values, and
> >  those values can change (vary) over the course of your
> >  program.
>
> This is partially incorrect.  If the value referred to by the name is
> immutable, then it cannot change; perhaps you meant to say that which
> object the name points to can vary over time?

I agree. Names are not Python's variables.

If anything in Python is a “variable” as generally understood, it is not
a name. It is a *binding*, from a reference (a name, or some other
reference like a list item) to a value.

It is the binding which can change over the course of the program, so
that is the variable.

-- 
 \        “Good judgement comes from experience. Experience comes from |
  `\                              bad judgement.” —Frederick P. Brooks |
_o__)                                                                  |
Ben Finney




More information about the Python-list mailing list