The “does Python have variables?” debate

Marko Rauhamaa marko at pacujo.net
Wed May 7 02:18:29 EDT 2014


Ned Batchelder <ned at nedbatchelder.com>:

> Why is "variable" sacrosanct and can only be used to describe C
> semantics, but we're OK reusing class, int, and function?

The Python language specification calls them variables; the terminology
discussion should end there.

The complaint against variables seems to hinge on the fact that Python
variables are not first-class objects. A manifestation of that is that
you can't pass variables by reference to functions.

Actually, while Python variables are not first-class objects, one could
see them as dictionary-key pairs. So you can even pass them by reference
by passing the dictionary and the key.

Then the problem is lists. You can't represent a list element as a
dictionary-key pair. Or can you? A list can be viewed as a "dictionary"
whose key is an integer. Thus, the same pass-by-reference technique
would work for lists as well.


Marko



More information about the Python-list mailing list