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

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to