Terry Reedy udel.edu> writes:
> I would change this to
> "local name 'bob' used before the assignment that makes it a local name"
>
> Calling names 'variables' is itself a point of confusion.
+1
___
Python-Dev mailing list
Python-Dev@python.org
http
On Tue, May 10, 2011 at 6:38 PM, Steven D'Aprano wrote:
> I don't know why it was thought necessary to distinguish between them in the
> first place.
New users almost constantly expressed confusion by NameError when the name
was clearly bound at global scope, and a subsequent assignment caused it
Nick Coghlan wrote:
Personally, I would just add "in current scope" to the existing error
message for the unbound local case (and potentially collapse the
exception hierarchy a bit by setting UnboundLocalError = NameError).
-0
That was the case prior to Python 2.0. Reverting is potentially a
> > > # Early reference to local
> > > UnboundLocalError: local variable 'bob' referenced before assignment
> >
> > I would change this to
> > "local name 'bob' used before the assignment that makes it a local name"
> >
> > Calling names 'variables' is itself a point of confusion.
>
> Yes, your p
On Tue, 10 May 2011 13:56:58 -0400, Terry Reedy wrote:
> On 5/10/2011 10:59 AM, Nick Coghlan wrote:
> > On Tue, May 10, 2011 at 11:11 PM, R. David Murray
> > wrote:
> >> How about:
> >>
> >> "reference to variable 'y' precedes an assignment that makes it a local
> >> variable"
> >
> > For compar
On 5/10/2011 10:59 AM, Nick Coghlan wrote:
On Tue, May 10, 2011 at 11:11 PM, R. David Murray wrote:
How about:
"reference to variable 'y' precedes an assignment that makes it a local
variable"
For comparison, the error messages I was able to elicit from 2.7 were
as follows:
# Module level
N
On Wed, 11 May 2011 00:59:08 +1000, Nick Coghlan wrote:
> On Tue, May 10, 2011 at 11:11 PM, R. David Murray w=
> rote:
> > How about:
> >
> > "reference to variable 'y' precedes an assignment that makes it a local
> > variable"
>
> For comparison, the error messages I was able to elicit from 2.7
On Tue, May 10, 2011 at 11:11 PM, R. David Murray wrote:
> How about:
>
> "reference to variable 'y' precedes an assignment that makes it a local
> variable"
For comparison, the error messages I was able to elicit from 2.7 were
as follows:
# Module level
NameError: name 'bob' is not defined
# F
On Tue, May 10, 2011 at 16:11, R. David Murray wrote:
> On Tue, 10 May 2011 08:36:38 +0300, Eli Bendersky
> 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 befo
On Tue, 10 May 2011 08:36:38 +0300, Eli Bendersky 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'
[forwarded to the python-ideas list]
Stefan
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
On Mon, May 9, 2011 at 18:44, Isaac Morland wrote:
> On Mon, 9 May 2011, Eli Bendersky wrote:
>
> x = 5
>>> def foo ():
>>> print (x)
>>> if bar ():
>>> x = 1
>>> print (x)
>>>
>>>
>> I wish you'd annotate this code sample, what do you intend it to
>> demonstrate?
On 5/9/2011 9:27 AM, Stefan Behnel wrote:
Eli Bendersky, 09.05.2011 14:56:
It's a known Python gotcha (*) that the following code:
x = 5
def foo():
print(x)
x = 1
print(x)
foo()
Will throw:
UnboundLocalError: local variable 'x' referenced before assignment
On the usage of 'x' in the *first*
Eli Bendersky wrote:
I think you are making an unwarranted assumption about what is "more
expected". I presume you are thinking that the expected behaviour is that
foo() should:
print global x (5)
assign 1 to local x
print local x (1)
If we implemented this change, there would be no more questi
On Mon, 9 May 2011, Eli Bendersky wrote:
x = 5
def foo ():
print (x)
if bar ():
x = 1
print (x)
I wish you'd annotate this code sample, what do you intend it to
demonstrate?
It probably shows the original complaint even more strongly. As for being a
proble
On Tue, May 10, 2011 at 1:06 AM, Eli Bendersky wrote:
> It probably shows the original complaint even more strongly. As for being a
> problem with the suggested solution, I suppose you're right, although it
> doesn't make it much different. Still, before a *possible* assignment to
> 'x', it should
On Tue, May 10, 2011 at 1:01 AM, Eli Bendersky wrote:
>
>> I think you are making an unwarranted assumption about what is "more
>> expected". I presume you are thinking that the expected behaviour is that
>> foo() should:
>>
>> print global x (5)
>> assign 1 to local x
>> print local x (1)
>>
>> I
> x = 5
> def foo ():
>print (x)
>if bar ():
>x = 1
>print (x)
>
I wish you'd annotate this code sample, what do you intend it to
demonstrate?
It probably shows the original complaint even more strongly. As for being a
problem with the suggested solution, I
> I think you are making an unwarranted assumption about what is "more
> expected". I presume you are thinking that the expected behaviour is that
> foo() should:
>
> print global x (5)
> assign 1 to local x
> print local x (1)
>
> If we implemented this change, there would be no more questions abo
Eli Bendersky wrote:
Hi all,
It's a known Python gotcha (*) that the following code:
x = 5
def foo():
print(x)
x = 1
print(x)
foo()
Will throw:
UnboundLocalError: local variable 'x' referenced before assignment
I think part of the problem is that UnboundLocalError is a ja
On May 9, 2011 6:59 AM, "Eli Bendersky" wrote:
>
> Hi all,
>
> It's a known Python gotcha (*) that the following code:
>
> x = 5
> def foo():
> print(x)
> x = 1
> print(x)
> foo()
>
> Will throw:
>
>UnboundLocalError: local variable 'x' referenced before assignment
>
> On the u
Eli Bendersky, 09.05.2011 14:56:
It's a known Python gotcha (*) that the following code:
x = 5
def foo():
print(x)
x = 1
print(x)
foo()
Will throw:
UnboundLocalError: local variable 'x' referenced before assignment
On the usage of 'x' in the *first* print. Recently, whi
On Mon, 9 May 2011, Eli Bendersky wrote:
It's a known Python gotcha (*) that the following code:
x = 5
def foo():
print(x)
x = 1
print(x)
foo()
Will throw:
UnboundLocalError: local variable 'x' referenced before assignment
On the usage of 'x' in the *first* print. Recently, wh
Hi all,
It's a known Python gotcha (*) that the following code:
x = 5
def foo():
print(x)
x = 1
print(x)
foo()
Will throw:
UnboundLocalError: local variable 'x' referenced before assignment
On the usage of 'x' in the *first* print. Recently, while reading the
zillionth quest
24 matches
Mail list logo