Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.01; 'dictionary': 0.07; 'subject:two': 0.07; 'python': 0.08; 'subject:parameters': 0.09; 'pm,': 0.10; 'received:209.85.214.174': 0.14; 'received:mail- iw0-f174.google.com': 0.14; 'wrote:': 0.14; 'angelico': 0.16; 'expressions,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'lambda': 0.16; 'messy': 0.16; 'on).': 0.16; 'subject:function': 0.16; 'tue,': 0.17; 'header:In-Reply-To:1': 0.21; 'trying': 0.23; 'parameters.': 0.23; 'code': 0.24; 'statement': 0.26; 'saying': 0.26; 'tried': 0.27; 'message- id:@mail.gmail.com': 0.28; 'language.': 0.28; 'received:209.85.214': 0.28; 'functions.': 0.29; 'variables': 0.29; 'instead': 0.29; 'implement': 0.30; 'for,': 0.30; 'if,': 0.30; 'nested': 0.30; "skip:' 10": 0.32; 'does': 0.33; 'to:addr :python-list': 0.33; 'chris': 0.34; 'daniel': 0.34; 'example,': 0.35; 'using': 0.35; 'supporting': 0.37; 'received:google.com': 0.37; 'something': 0.37; 'received:209.85': 0.37; 'but': 0.38; 'implemented': 0.38; 'subject:: ': 0.38; 'subject: (': 0.39; 'received:209': 0.39; 'map': 0.39; 'to:addr:python.org': 0.39; 'simply': 0.60; 'your': 0.60; 'levels': 0.63; '31,': 0.65; 'due': 0.67; 'isolated': 0.84; 'technically': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=Xz9ywN1IYo2Bfxb+7sQWkaSCvyfXF1RVZMhat0fafxU=; b=IVY9xumB7Du7Bun7vY5g+Ty9w+LanliKpNIVNiPsYrADFFGt0QDuhuquKZl14c8cxN rcdB6tbAjONK/CPNC/qz/FGc48v3lt5ITv+QkV6rQK3e6ccYuIjUsFVn+yfDA7/hfGtc rBxsPnY0pCizhAiFQ5nKz70X0G1fLIJMuJ2os= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=o0eaeT3Yjv09eHoRltan4xJFCZbkaBtuG+gINbRSqQmmfRcT+S0PehXDIIScMBb5HN JoatQvVR2AgzxtIUfd4aKx0o4SShi2h+0WRcAgQwL0MjlRAzW1r16FZ2Hy2x8N/1UkCB 6ZfGzout9760dLBLkR5Vb4/qNByb3ZHVM/tU4= MIME-Version: 1.0 In-Reply-To: References: Date: Tue, 31 May 2011 13:34:43 +1000 Subject: Re: scope of function parameters (take two) 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.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: 21 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1306812886 news.xs4all.nl 49182 [::ffff:82.94.164.166]:37131 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:6699 On Tue, May 31, 2011 at 1:18 PM, Daniel Kluev wrote: > On Tue, May 31, 2011 at 2:05 PM, Chris Angelico wrote: >> Infinitely-nested scoping is simply one of the casualties of a >> non-declarative language. > > Well, this is not accurate, as you can have 'infinitely-nested > scoping' in python, in form of nested functions. For example, you can > use map(lambda x: map/filter/reduce/lambda's>, list_of_x), and you will have your > isolated scopes. Although due to lambdas supporting only expressions, > following this style leads to awkward and complicated code (and/or > instead if, map instead for, and so on). That's an incredibly messy workaround, and would get ridiculous if you tried going many levels in. It's like saying that a C-style 'switch' statement can be implemented in Python using a dictionary of lambdas... and then trying to implement fall-through. But you're right; a lambda does technically create something of a nested scope - albeit one in which the only internal variables are its parameters. Chris Angelico