Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: 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; 'python,': 0.02; 'subject:IDLE': 0.04; 'editor.': 0.09; 'def': 0.12; 'windows': 0.15; "'q'": 0.16; 'a()': 0.16; 'a():': 0.16; 'b()': 0.16; 'b():': 0.16; 'command-line': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:too': 0.16; 'syntaxerror:': 0.16; 'throw': 0.16; 'trying': 0.19; 'typing': 0.19; '>>>': 0.22; 'fine': 0.24; "doesn't": 0.30; 'mode': 0.30; 'message-id:@mail.gmail.com': 0.30; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'idle': 0.36; 'doing': 0.36; 'subject:?': 0.36; 'too': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'name': 0.63; 'subject:being': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=8NOURDfwbComvRiZ6RkZAxJdRE9UwCIaE6VoThThCxQ=; b=mYgM9hf1Yn4pvKvZEdASSt1NbKBTujWsHN+0PWq9ZSzSXNDLvvSEmmK3rGVFv5i307 g4Rr+8VGkz+DjmKANKMzMfzbUHsArRsq0mKht0z82RSIh74BLlE+f3lBvSf1kP/2wZme 3jn9UnqpEgLxiAEiS5dKXtco6UTx2q4zqhOyazZEwpj/nuM2f38pyZa30mCUUyJtzQ6u 6CM7rTmYc7ReXgIy/MEGknHDXLW9qCe+zKVA5F6+elYnxhTqhuzDXZho9MwUy2MYWfHj kt1N9cbNA0G0FwscN8UhhVePiZ9WcPF6rQAc9FJyOaOJ+0+u4iDQv+MgoRuafiRiRVhB 0bpA== MIME-Version: 1.0 X-Received: by 10.68.96.130 with SMTP id ds2mr17841187pbb.99.1382367961005; Mon, 21 Oct 2013 08:06:01 -0700 (PDT) Date: Tue, 22 Oct 2013 02:06:00 +1100 Subject: IDLE being too clever checking nonlocal declarations? From: Chris Angelico 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1382367965 news.xs4all.nl 15925 [2001:888:2000:d::a6]:42845 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:57194 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