On 10/31/2012 9:20 PM, Terry Reedy wrote: > On 10/31/2012 4:28 PM, R. David Murray wrote: >> "local variable referenced before assignment" *is* >> a pointer to the concept of when global variables become local...perhaps >> there is a better wording, do you have a suggestion? > > The current wording is an exact, concise, description of the problem. > Rather than tinkering with the wording, I think a more general solution > might be a new HOWTO: Understanding exception messages. It could have > alphabetically sorted entries for exceptions and messages that people > find problematic. > > UnboundLocalError > local variable referenced before assignment > > Problem: You used a local name 'x' in an expression before you assigned > it a value. So the interpreter could not compute the value of the > expression. Remember that assignment makes a name local unless it is > declared global or nonlocal. > > Remedy: If you intend 'x' to refer to a glocal or nonlocal name, add the > necessary global or nonlocal declaration. If you intend <left out> 'x' to be local, rearrange your code to give it a value before you use it. -- Terry Jan Reedy
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4