How to Teach Python "Variables"

Paul Rudin paul.nospam at
Wed Nov 28 09:18:43 CET 2007

none <""atavory\"@(none)"> writes:

> 	IIRC, I once saw an explanation how Python doesn't have
> "variables" in the sense that, say, C does, and instead has bindings
> from names to objects. Does anyone have a link?

"Variable" is an abstract concept, and it's a slightly different
concept for every programming language. So you're correct to say that
they're not like C variables. But putting it that way is no more valid
than saying that C doesn't have variables like Python's.

If you're teaching it from first principles then I wouldn't start by
saying what they're not, if people don't know what C variables are
then it doesn't help to say "these Python variables are not like C
variables". If they do know about variables in other languages, it
might help to say "forget your preconceptions about what a variable

As you say, in Python variables are essentially names in some kind of
lookup table for objects... this is a perfectly reasonable way to try
and explain the idea (and is essentially the way it's
implemented). Then you have to get into scoping, and the odd gotcha
(e.g. contrast assigning to a global variable in local scope with
referencing one - with and without a "global" statement).

More information about the Python-list mailing list