Another dumb scope question for a closure.

Fredrik Lundh fredrik at
Thu Jan 10 22:21:16 CET 2008

Steven W. Orr wrote:

> The problem only happens if I try to modify jj.

It only happens if you try to *bind* the name "jj" to an object inside 
the function.

> What am I not understanding?

My guess is that you have a C/C++ view of variables and values, where 
variables are locations in memory that can hold values.  In Python, such 
locations are called objects, and they may or may not have names bound 
to them (via assignments).

This might help:

Then read

and finally read the "Naming and binding" page again.


More information about the Python-list mailing list