Newcomer question wrt variable scope/namespaces

Florian Daniel Otel florian.otel at
Wed Jan 18 08:02:37 EST 2006

Mike, Gary, Magnus

First of all, thanks to you all for the clarifications.

On 1/14/06, Mike Meyer <mwm at> wrote:
> Python variables are just names. They refer to (are "bound" to)
> objects. An assignment statement doesn't change a value. It rebinds
> the variable (or lvalue) to the value on the right side of the
> statement.
> The Python rule is that you can only bind a local variable or a
> variable declared global. It doesn't say anything at all about what
> you can do to the objects so bound.

Based on Mike explanation and Gary and Magnus illustrative examples
(and a perusal of the  Chapter 4 from my current bible -- "Python in a
Nutshell") I now understood the way Python handles varialbles, objects
(mutable or not) and the bindings between the two.

As Mike figured it out, coming from a "low-level" language (e.g. C,
where "call by value" and "call by reference" are like night&day and
memory mngmnt is to be handled explicitely)  was a bit of a challenge.
Even if I am not exactly new to programming it wasn't quite obvious in
the first place how Python handles the mapping btw lvalues and rvalues
(the s.c. "variable binding") and how object and (respectively)
variable scoping works.  One can only wish that various python texts
(like e.g. the official Python tutorial) would be more forthcoming on
this fundamental paradigm shift.

Anyway, thanks Mike, Gary and Magnus for the very useful hints and


More information about the Python-list mailing list