Newline in bash, was Re: IDLE being too clever checking nonlocal declarations?

2013-10-22 Thread Peter Otten
Steven D'Aprano wrote: > On Mon, 21 Oct 2013 23:26:28 -0400, Terry Reedy wrote: > >> On 10/21/2013 7:52 PM, Steven D'Aprano wrote: >>> On Mon, 21 Oct 2013 15:51:56 -0400, Terry Reedy wrote: >>> On 10/21/2013 11:06 AM, Chris Angelico wrote: > Try typing this into IDLE: > def

Re: IDLE being too clever checking nonlocal declarations?

2013-10-21 Thread Chris Angelico
On Tue, Oct 22, 2013 at 4:57 PM, Steven D'Aprano wrote: > Yep, I got that, but what I'm saying is that it is too strict to raise > the exception at the point where it sees "nonlocal q". The CPython > interpreter allows q to be defined inside function a but after function > b, e.g. this is allowed:

Re: IDLE being too clever checking nonlocal declarations?

2013-10-21 Thread Steven D'Aprano
On Mon, 21 Oct 2013 23:26:28 -0400, Terry Reedy wrote: > On 10/21/2013 7:52 PM, Steven D'Aprano wrote: >> On Mon, 21 Oct 2013 15:51:56 -0400, Terry Reedy wrote: >> >>> On 10/21/2013 11:06 AM, Chris Angelico wrote: Try typing this into IDLE: >>> def a(): def b():

Re: IDLE being too clever checking nonlocal declarations?

2013-10-21 Thread Terry Reedy
On 10/21/2013 7:52 PM, Steven D'Aprano wrote: On Mon, 21 Oct 2013 15:51:56 -0400, Terry Reedy wrote: 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 thr

Re: IDLE being too clever checking nonlocal declarations?

2013-10-21 Thread Steven D'Aprano
On Mon, 21 Oct 2013 15:51:56 -0400, Terry Reedy wrote: > 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 c

Re: IDLE being too clever checking nonlocal declarations?

2013-10-21 Thread Terry Reedy
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, th

Re: IDLE being too clever checking nonlocal declarations?

2013-10-21 Thread Chris Angelico
On Tue, Oct 22, 2013 at 3:09 AM, Peter Otten <__pete...@web.de> wrote: > Chris Angelico wrote: >> But typing this into IDLE interactive mode requires some fiddling >> around with the editor. Is it trying to be too clever? Am I doing >> something that makes no sense? > > Yes, but you should still fi

Re: IDLE being too clever checking nonlocal declarations?

2013-10-21 Thread Peter Otten
Chris Angelico wrote: > Try typing this into IDLE: > def a(): > def b(): > nonlocal q > SyntaxError: no binding for nonlocal 'q' found > > > In interactive command-line Python, this doesn't throw an error, and > it works fine if the name is used later: > def a(): > de

IDLE being too clever checking nonlocal declarations?

2013-10-21 Thread Chris Angelico
Try typing this into IDLE: >>> def a(): def b(): nonlocal q SyntaxError: no binding for nonlocal 'q' found In interactive command-line Python, this doesn't throw an error, and it works fine if the name is used later: >>> def a(): def b(): nonlocal q q+=1 q=1