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 command line, that is > what you see.
Arguably, that's also too strict, but these *four* lines work fine interactively: py> def a(): ... def b(): ... nonlocal q ... q = 1 ... and also from the command line: [steve@ando ~]$ python3.3 -c "def a(): > def b(): > nonlocal q > q = 1 > " so it should also work in IDLE. -- Steven -- https://mail.python.org/mailman/listinfo/python-list