On Tue, 10 May 2011 08:36:38 +0300, Eli Bendersky <eliben@gmail.com> wrote:
> With an unlimited error message length it could make sense to say "Hey, I
> see 'x' may be assigned in this scope, so I mark it local. But this access
> to 'x' happens before assignment - so ERROR". This isn't realistic, of
> course, so I'm wondering:
>
> 1. Does this error message (although unrealistic) capture all possible
> appearances of UnboundLocalError?
> 2. If the answer to (1) is yes - could it be usefully shortened to be
> clearer than the current "local variable referenced before assignment"?
>
> This may not be possible, of course, but it doesn't harm trying :-)

How about:

"reference to variable 'y' precedes an assignment that makes it a local
variable"

Yes, this is much better and not too long IMHO
Eli 

">

(original) (raw)



On Tue, May 10, 2011 at 16:11, R. David Murray <rdmurray@bitdance.com> wrote:
On Tue, 10 May 2011 08:36:38 +0300, Eli Bendersky <eliben@gmail.com> wrote:
> With an unlimited error message length it could make sense to say "Hey, I
> see 'x' may be assigned in this scope, so I mark it local. But this access
> to 'x' happens before assignment - so ERROR". This isn't realistic, of
> course, so I'm wondering:
>
> 1\. Does this error message (although unrealistic) capture all possible
> appearances of UnboundLocalError?
> 2\. If the answer to (1) is yes - could it be usefully shortened to be
> clearer than the current "local variable referenced before assignment"?
>
> This may not be possible, of course, but it doesn't harm trying :-)

How about:

"reference to variable 'y' precedes an assignment that makes it a local
variable"

Yes, this is much better and not too long IMHO
Eli