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/122511.html below:

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

[Python-Dev] Improve error message "UnboundLocalError: local variable referenced before assignment"Chris Angelico rosuav at gmail.com
Thu Nov 1 02:45:44 CET 2012
On Thu, Nov 1, 2012 at 12:20 PM, Terry Reedy <tjreedy at udel.edu> wrote:
> 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
> ...
> Remedy: If you intend 'x' to refer to a glocal or nonlocal name, add the
> necessary global or nonlocal declaration. If you intend

+1. Can this be tied in with help(UnboundLocalError) perhaps? At the
moment, that produces a huge screed of details that aren't
particularly helpful to a novice (all its methods etc), and only a
one-line explanation "Local name referenced but not bound to a
value.". If that could be shortened and expanded on, it'd be a logical
place to point people. "You got an error you don't understand? Go to
the interactive interpreter and type help(NameOfError) - that should
tell you what it is."

ChrisA
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