This is just normal python. When you want to assign to a global variable inside a function, you have to declare the variable as a global: _stateVariable = 0 class def func()
global _stateVariable
_stateVariable = 1
-Randy -----Original Message----- From: Andrew Athan [mailto:aathan-zope-list%REMOVEME@memeplex.com] Sent: Friday, April 06, 2001 1:01 PM To: zope@zope.org Subject: RE: [Zope] Verrryy strange behavior (NameError) I'm sending this in case my sagga helps some other relative newcomer. I suspect this problem has something to do with python1.5.2's (or Zope's hackery of...) handling of namespaces within modules & classes. What I needed was access to a "static global" variable to store some state for me. (No, I haven't looked into threads, their existance, or such issues in Zope). What I was doing was: _stateVariable=0 .... class .... def fun() .... _stateVariable=1 and this was causing me all kinds of grief. By changing the code to _stateVariable = {'a':0} ... class ... def fun() ... _stateVariable['a']=1 everything works just fine. Now, can someone give me the shortcut to understand WHHHYYY? A.