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


Groups > comp.lang.python > #57197

Re: IDLE being too clever checking nonlocal declarations?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'subject:IDLE': 0.04; 'editor.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'def': 0.12; 'bug': 0.12; 'windows': 0.15; "'q'": 0.16; 'a()': 0.16; 'a():': 0.16; 'b()': 0.16; 'b():': 0.16; 'command-line': 0.16; 'outdated': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:too': 0.16; 'syntaxerror:': 0.16; 'throw': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'typing': 0.19; 'header:User- Agent:1': 0.23; 'fine': 0.24; 'versions': 0.24; 'looks': 0.24; 'header:X-Complaints-To:1': 0.27; 'chris': 0.29; "doesn't": 0.30; 'mode': 0.30; '>>>>': 0.31; 'file': 0.32; 'linux': 0.33; 'something': 0.35; 'but': 0.35; 'idle': 0.36; 'doing': 0.36; 'subject:?': 0.36; 'should': 0.36; 'too': 0.37; 'confirmed': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'name': 0.63; 'affected.': 0.84; 'subject:being': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: IDLE being too clever checking nonlocal declarations?
Date Mon, 21 Oct 2013 18:09:08 +0200
Organization None
References <CAPTjJmpEaQxN10eSU2YzZZ-4wMoT3K=iFBYQqgBx_RZ3AWyfTw@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p5084b459.dip0.t-ipconnect.de
User-Agent KNode/4.7.3
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1314.1382371766.18130.python-list@python.org> (permalink)
Lines 35
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1382371766 news.xs4all.nl 15947 [2001:888:2000:d::a6]:58921
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:57197

Show key headers only | View raw


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():
>     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?

Yes, but you should still file a bug report ;)
 
> Tested with 3.3.0 on Windows XP.

Confirmed on Linux for 3.2.2, 3.3.0, and an outdated built of 3.4. It looks 
like all versions of Python 3 are affected.

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


Thread

Re: IDLE being too clever checking nonlocal declarations? Peter Otten <__peter__@web.de> - 2013-10-21 18:09 +0200

csiph-web