How to Teach Python "Variables"

Chris Mellon arkanes at gmail.com
Wed Nov 28 12:23:42 EST 2007


On Nov 28, 2007 10:57 AM, hdante <hdante at gmail.com> wrote:
> On Nov 28, 2:12 pm, "Chris Mellon" <arka... at gmail.com> wrote:
> >
> > Right. Python variables are pointers, except for all the ways that
> > they are different. By the same criteria, they are also puppies. Give
> > it a rest.
>
>  I'm sorry if your notion of pointer is incorrect. A pointer (or, more
> formally, a reference) is an object that points to some value. A
> python variable isn't different than that in any way.
>

A python name isn't an object. The difference between names and
objects is at the core of this entire conversation. In fact, you are
exactly the sort of person this discussion was targeted at, because
you don't understand the difference.

You can play semantic games if you want and just declare that
everything is the same at some fundamental level. It's a little like
taking your ball and going home, because insisting on names that don't
indicate the differences between things is useless at best and harmful
at worst.

Whether you like it or not, the term "pointer" has a specific common
meanings. They do not mean "any means by which you may reference a
value". "variable" is certainly less clear and is used much more
loosely, but in the specific context of comparison to C, python
name/object bindings are not the same as C variables.

Pointers are values. They also point at other values, and those values
may be other pointers, ad infinitum. Understanding this is core to
understanding and using pointers.

Python names are *not* values, and all they do is tag a specific
object in a specific namespace. You can't have a name that refers to
another name, names can only refer to objects. Understanding this is
core to understanding and using the Python object model, *especially*
if some nitwit has been telling you that they're the same as pointers.



More information about the Python-list mailing list