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


Groups > comp.lang.python > #57239

Re: IDLE being too clever checking nonlocal declarations?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:IDLE': 0.04; 'cpython': 0.05; 'interpreter': 0.05; 'assignment': 0.07; 'strict': 0.07; '22,': 0.09; 'def': 0.12; 'bug': 0.12; 'a():': 0.16; 'b():': 0.16; 'declaration': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'sees': 0.16; 'subject:too': 0.16; 'valid.': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'module': 0.19; 'else,': 0.19; 'typing': 0.19; 'seems': 0.21; 'issue.': 0.22; 'saying': 0.22; 'stopping': 0.24; 'define': 0.26; 'tracker': 0.26; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'function': 0.29; 'raise': 0.29; 'thus': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; "d'aprano": 0.31; 'steven': 0.31; 'allows': 0.31; 'problem': 0.35; 'info': 0.35; 'something': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'idle': 0.36; 'thanks': 0.36; 'subject:?': 0.36; 'too': 0.37; 'being': 0.38; 'e.g.': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'strictly': 0.61; 'back': 0.62; 'analysis': 0.75; 'subject:being': 0.84; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=UHvwX2ArqISlja80uzZMQOh0bgTB+rRTibklYHbCho8=; b=p7YrbNTwhdFVe4ur5Ese58CaYJ270Fh9assTfvwdGpv6aDEBAL+DMUZ8IitM98Ct0L PB7QFAy9dnYXAZPq7G2FZ41428oNIOh2+tmjG6+I9Sf/tebo1OkCKEQDXiypxC+6Ajis +Eau6RRDSPhm71zurmGPVr3Ij1mh5kEE5OCTc4/D/2GnvXpRRUoqyECyR7jKO2EozxFD rC+uTwMm5xgJpw1mDSalYYLb63i9sTfa/HAy6QgbgiatenxM65OU3U4qItcqsWAuuYVG hOLNn6iglrz+4I+WU3HWYHCwlXO2ruJtJ6UaP6yNNOqzOOUZ9QXyG9I8EreOjvTj2xLI o1Mw==
MIME-Version 1.0
X-Received by 10.66.157.165 with SMTP id wn5mr1285785pab.169.1382423047873; Mon, 21 Oct 2013 23:24:07 -0700 (PDT)
In-Reply-To <526613ae$0$30000$c3e8da3$5496439d@news.astraweb.com>
References <CAPTjJmpEaQxN10eSU2YzZZ-4wMoT3K=iFBYQqgBx_RZ3AWyfTw@mail.gmail.com> <mailman.1316.1382385139.18130.python-list@python.org> <5265be56$0$29981$c3e8da3$5496439d@news.astraweb.com> <mailman.1332.1382412405.18130.python-list@python.org> <526613ae$0$30000$c3e8da3$5496439d@news.astraweb.com>
Date Tue, 22 Oct 2013 17:24:07 +1100
Subject Re: IDLE being too clever checking nonlocal declarations?
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
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.1338.1382423051.18130.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1382423051 news.xs4all.nl 15969 [2001:888:2000:d::a6]:49946
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:57239

Show key headers only | View raw


On Tue, Oct 22, 2013 at 4:57 PM, Steven D'Aprano <steve@pearwood.info> 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:
>
> def a():
>     def b():
>         nonlocal q
>         q += 1
>     q = 2  # <=======
>
>
> If IDLE and the code.py module requires q to be strictly defined before
> function b, then it is too strict. Your analysis of the bug as being in
> code.py seems plausible.

Yeah. I came across this as I was knocking together a test for
something else, and my work-around was to define the inner function as
just "pass", and then go back and edit in the nonlocal declaration
after adding the assignment outside. The only problem is that it's
syntax-checking something that's only half-entered, and is bombing on
it - thus stopping you from typing in the bit that would make it
valid.

Thanks Terry for the extra info on the tracker issue.

ChrisA

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


Thread

Re: IDLE being too clever checking nonlocal declarations? Terry Reedy <tjreedy@udel.edu> - 2013-10-21 15:51 -0400
  Re: IDLE being too clever checking nonlocal declarations? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-21 23:52 +0000
    Re: IDLE being too clever checking nonlocal declarations? Terry Reedy <tjreedy@udel.edu> - 2013-10-21 23:26 -0400
      Re: IDLE being too clever checking nonlocal declarations? Steven D'Aprano <steve@pearwood.info> - 2013-10-22 05:57 +0000
        Re: IDLE being too clever checking nonlocal declarations? Chris Angelico <rosuav@gmail.com> - 2013-10-22 17:24 +1100
        Newline in bash, was Re: IDLE being too clever checking nonlocal declarations? Peter Otten <__peter__@web.de> - 2013-10-22 09:20 +0200

csiph-web