Changing global variables in tkinter/pmw callback

Fredrik Lundh fredrik at pythonware.com
Fri Apr 6 03:28:46 EDT 2001


Brian Elmegaard wrote:
> Still, I think I am too much of a Fortran programmer to really
> understand why it is not possible to change the binding of a reference
> (correct term?) to another object just by assignment.

you keep forgetting the "assignment modifies namespaces, not
objects" rule.

to change the object a name points to, you must modify the
namespace that name lives in.  changing your own namespace
(like "s=10" usually does) isn't enough.

using a shared container object is one way to work around
this; when you do that, the changes are visible to anyone
watching the container.

(consider sharing a storage locker down at the railway station
for some suspicious activity.  as long as we both use the same
locker, I can put some money in there, and you can take the
money and leave some contraband scripts.  but if you suddenly
decide to use a different locker without telling me, our business
will suffer...)

Cheers /F





More information about the Python-list mailing list