Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed5.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.035 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'subject:Function': 0.09; 'url:peps': 0.09; 'am,': 0.12; 'bit.': 0.16; 'closures': 0.16; 'declaration': 0.16; 'parks': 0.16; 'read-only.': 0.16; 'travis': 0.16; 'cc:addr:python-list': 0.16; 'question.': 0.16; 'wrote:': 0.16; 'wed,': 0.17; 'cheers,': 0.18; 'cc:no real name:2**0': 0.20; 'cc:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'aug': 0.24; "i'm": 0.27; 'message-id:@mail.gmail.com': 0.29; 'cc:addr:python.org': 0.30; 'disappointed': 0.30; 'url:dev': 0.30; 'chris': 0.32; 'quite': 0.34; 'received:209.85.161': 0.35; 'url:python': 0.36; 'question': 0.36; 'skip:" 10': 0.36; 'assuming': 0.37; 'variables': 0.37; 'received:google.com': 0.38; 'url:org': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'url:docs': 0.39; 'your': 0.61; '31,': 0.64; 'url:3': 0.67; 'day': 0.69; 'details.': 0.71; 'realized': 0.73; '9:45': 0.84; 'sender:addr:chris': 0.84; 'url:reference': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=6gYrnSjCt2sTBl/f9DVJlIatyYVj1NP0lnI12rCynLs=; b=ChSK6lmNi8w95/r98nhjALjDrYJgMp+ViCYJhmptAcXkM+Zqs17G5s8qxQjKjrBNWi J9MIM9z6zn/S6y7aph6WQI8Cd8npTVD5bp/moYvj3o1fIBybEfVNLFVS9gZJbvMELJos Xm/YH4UeGFpIomniM98XKF2lpuGFNSshZGrAg= MIME-Version: 1.0 Sender: chris@rebertia.com In-Reply-To: <9cd48486-acd9-4888-9677-0e54fd1eedfd@k15g2000yqd.googlegroups.com> References: <9cd48486-acd9-4888-9677-0e54fd1eedfd@k15g2000yqd.googlegroups.com> Date: Wed, 31 Aug 2011 10:18:57 -0700 X-Google-Sender-Auth: zgV4CODLcwExz8kaaEuSTeKnt8k Subject: Re: Closures and Partial Function Application From: Chris Rebert To: Travis Parks Content-Type: text/plain; charset=UTF-8 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 12 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1314811146 news.xs4all.nl 2480 [2001:888:2000:d::a6]:38491 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:12505 On Wed, Aug 31, 2011 at 9:45 AM, Travis Parks wrote: > I was a little disappointed the other day when I realized that > closures were read-only. I like to use closures quite a bit. Assuming I'm intuiting your question correctly, then you're incorrect; they are "read/write". You just need a `nonlocal` declaration for the variables in question. See http://www.python.org/dev/peps/pep-3104/ and http://docs.python.org/release/3.1.3/reference/simple_stmts.html#nonlocal for details. Cheers, Chris