Vincent Wehren vincent at
Sat Mar 12 07:50:43 CET 2005

steve wrote:
> In a nutshell, my problem is that I am getting this runtime error, and
> I have no clue why.  Please bear in mind its my first python program:
> "localvariable 'currentAbility' referenced before asignment"

If you're assigning an object to a name, it will be assigned to that 
name in local namespace. So, in your case, you are doing augmented 
assignment on a local name that does not yet exist (hence the error 
message). You need to tell the interpreter that what you want is assign 
to that name in global namespace. You can do this by using the 'global' 
statement, as in:

 >>> my_global = 1
 >>> def some_func():
...    global my_global
...    my_global += 1
 >> some_func()
 >> my_global


Vincent Wehren

More information about the Python-list mailing list