A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2012-November/122510.html below:

[Python-Dev] Improve error message "UnboundLocalError: local variable referenced before assignment"

[Python-Dev] Improve error message "UnboundLocalError: local variable referenced before assignment" [Python-Dev] Improve error message "UnboundLocalError: local variable referenced before assignment"Terry Reedy tjreedy at udel.edu
Thu Nov 1 02:20:01 CET 2012
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



-- 
Terry Jan Reedy

More information about the Python-Dev mailing list

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