[Zope] local variable

Dieter Maurer dieter@handshake.de
Mon, 17 Mar 2003 21:32:28 +0100


D. Rick Anderson wrote at 2003-3-15 23:21 -0800:
 > I've got a python script that sets a variable:
 > 
 >     notes_eo_counter = 0 
 > 
 > And then defines a function:
 > 
 >     def printNotesRow(columns):
 >             ....
 > ...
 > This has worked just fine in several scripts, but in this particular one
 > I'm gettin an error:
 > 
 > Error Type: UnboundLocalError
 > Error Value: local variable 'notes_eo_counter' referenced before
 > assignment

The problem is that you write to the variable:

  Variables from an outer scope are read automatically.
  However, as soon as you assign to a variable, you
  must declare it as from the outer scope.

  Please read the Python reference manual for more information.


Dieter