Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'compiler': 0.07; 'cc:addr :python-list': 0.11; 'missed': 0.12; '1234': 0.16; 'declaration': 0.16; 'declared': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'globals': 0.16; 'globals.': 0.16; 'referencing': 0.16; 'scope.': 0.16; 'subject:programming': 0.16; 'typos': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'module': 0.19; 'cc:addr:python.org': 0.22; 'certainly': 0.24; "shouldn't": 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "d'aprano": 0.31; 'steven': 0.31; 'could': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'catch': 0.60; "you're": 0.61; 'different': 0.65; 'mar': 0.68; 'to:none': 0.92; 'imagine': 0.93 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:cc :content-type; bh=xjUqVHOuQ0U2dxv6XvLIPg+RZCseqff4YPaZH2lTa+c=; b=YERQKvad15TGCWX9GXizBOT+ZoZ/Gi10Q+BFVglIFxFjybbqobbmeC7f4Ds/Ky2IOX IrZ5AKmkUkLLMfhy4em41xXzIINJehxBQPNsYempwEDeaQ/JDNH24Yx3GVBHe1cR/rJB Utvk1GcRus7y8/qdciSm6vPDYgBBEiimWJU76LWAlLltBmYz5Cz4bTiHqxiOEKGf3Cbg Hq9e3w7A62jNYwLZIzC3pS4K6YeF6IIiRdM4bAzIHOxuCQuNwAa3VzCH5ZzG9EwuFJuW PioksiAh8hJhGA/EkQ4i6X8Da7sEcj5sh5123eQBskDA3rD3EihIYxDwJJ0wPWkdyNvb HrFQ== MIME-Version: 1.0 X-Received: by 10.68.197.36 with SMTP id ir4mr476833pbc.46.1393949076836; Tue, 04 Mar 2014 08:04:36 -0800 (PST) In-Reply-To: <5315f52f$0$29985$c3e8da3$5496439d@news.astraweb.com> References: <4c7dbc57-eef9-4582-aecd-aac13a39b45f@googlegroups.com> <3b54a279-03a1-4a81-a428-ecad6eb16036@googlegroups.com> <216bb5f4-32c4-4f86-a9f4-1b0dd37a2a81@googlegroups.com> <0129a5b9-b85f-4ad5-b5e2-bfb2a48041d5@googlegroups.com> <5314bb96$0$29985$c3e8da3$5496439d@news.astraweb.com> <5315661c$0$2923$c3e8da3$76491128@news.astraweb.com> <53159540$0$2923$c3e8da3$76491128@news.astraweb.com> <5315eec0$0$29985$c3e8da3$5496439d@news.astraweb.com> <5315f52f$0$29985$c3e8da3$5496439d@news.astraweb.com> Date: Wed, 5 Mar 2014 03:04:36 +1100 Subject: Re: Functional programming From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393949085 news.xs4all.nl 2973 [2001:888:2000:d::a6]:51047 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67698 On Wed, Mar 5, 2014 at 2:45 AM, Steven D'Aprano wrote: >> Aside: If you declare your locals, you shouldn't need to declare your >> globals. Though I could imagine a rule that global rebinding still needs >> to be declared, but you certainly shouldn't need to declare nonlocal if >> you have a local declaration. Absence of local => nonlocal. > > You missed that the purpose of the declaration is to avoid accidental > typos: > > local process > procces = 1234 > > > With declarations, the compiler can catch some typos at compile-time. Yep, but if you're declaring all your locals (and globals get declared at module scope - they're just local to a different and broader scope), then "procces" will never have been declared anywhere. You shouldn't need to re-declare everything you're referencing from an outer scope. ChrisA