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


Groups > comp.lang.python > #57194 > unrolled thread

IDLE being too clever checking nonlocal declarations?

Started byChris Angelico <rosuav@gmail.com>
First post2013-10-22 02:06 +1100
Last post2013-10-22 02:06 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  IDLE being too clever checking nonlocal declarations? Chris Angelico <rosuav@gmail.com> - 2013-10-22 02:06 +1100

#57194 — IDLE being too clever checking nonlocal declarations?

FromChris Angelico <rosuav@gmail.com>
Date2013-10-22 02:06 +1100
SubjectIDLE being too clever checking nonlocal declarations?
Message-ID<mailman.1311.1382367965.18130.python-list@python.org>
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
    b()
    return q

>>> a()
2

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?

Tested with 3.3.0 on Windows XP.

ChrisA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web