Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #57200

Re: IDLE being too clever checking nonlocal declarations?

From Terry Reedy <tjreedy@udel.edu>
Subject Re: IDLE being too clever checking nonlocal declarations?
Date 2013-10-21 15:51 -0400
References <CAPTjJmpEaQxN10eSU2YzZZ-4wMoT3K=iFBYQqgBx_RZ3AWyfTw@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1316.1382385139.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 10/21/2013 11:06 AM, Chris Angelico wrote:
> Try typing this into IDLE:
>
>>>> def a():
>      def b():
>          nonlocal q
> SyntaxError: no binding for nonlocal 'q' found

If you submit those three lines to Python from the command line, that is 
what you see.

> In interactive command-line Python, this doesn't throw an error,
> it works fine if the name is used later:
>
>>>> def a():
>      def b():
>          nonlocal q
>          q+=1

I verified that interactive Python also syntax checks each line as 
entered, even for compound statements. Details should be left to the 
tracker issue you raised.

-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: IDLE being too clever checking nonlocal declarations? Terry Reedy <tjreedy@udel.edu> - 2013-10-21 15:51 -0400
  Re: IDLE being too clever checking nonlocal declarations? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-21 23:52 +0000
    Re: IDLE being too clever checking nonlocal declarations? Terry Reedy <tjreedy@udel.edu> - 2013-10-21 23:26 -0400
      Re: IDLE being too clever checking nonlocal declarations? Steven D'Aprano <steve@pearwood.info> - 2013-10-22 05:57 +0000
        Re: IDLE being too clever checking nonlocal declarations? Chris Angelico <rosuav@gmail.com> - 2013-10-22 17:24 +1100
        Newline in bash, was Re: IDLE being too clever checking nonlocal declarations? Peter Otten <__peter__@web.de> - 2013-10-22 09:20 +0200

csiph-web