Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'argument': 0.05; 'subject:Python': 0.06; 'explicit': 0.07; 'variables': 0.07; 'subject:language': 0.09; 'cc:addr:python- list': 0.11; 'python': 0.11; 'language.': 0.14; '(am': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'lambda': 0.16; 'so;': 0.16; 'subject: \n ': 0.16; 'sure.': 0.16; 'why,': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'function': 0.29; 'chris': 0.29; 'am,': 0.29; "doesn't": 0.30; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; 'work.': 0.31; '25,': 0.31; 'community': 0.33; 'trouble': 0.34; 'created': 0.35; 'case,': 0.35; 'point.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'there': 0.35; 'programming,': 0.36; 'right?': 0.36; "i'll": 0.36; 'so,': 0.37; 'clear': 0.37; 'implement': 0.38; 'needed': 0.38; 'pm,': 0.38; 'expect': 0.39; 'explain': 0.39; 'does': 0.39; 'functional': 0.39; 'users': 0.40; 'referred': 0.60; 'worth': 0.66; 'mar': 0.68; 'default': 0.69; 'subject:this': 0.83; 'confusion.': 0.84; 'understand,': 0.84; 'time)': 0.91; 'to:none': 0.92 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=dpnnNObbRVdKf4DFnqdqF034fqVxCWjfhaWCX89QlOA=; b=TDVKdwxJJbm63zOx5KwpWSx2jFDQBm+ELBEVC6bjIpkgEirhNYimNuVXQ5NMPaZZeC yaQmRS0ZJktYFetuhC5sFnk66cStHDHONwZFmHEnHPB4Hur5eK04oJDTOoelNHbYTaEa B++U1xaN1O2+laOwvMnEtSGwbr2otNbGp5XqD3of/qIqOhvvFmkukPAtjC/kBDjkMhbu VnpiDH4OY8Otp7dftEfi7fTLeAwQYPPv5r8cuRosyMERnh/12vtLYK5uOQYZj8yriPyY GLdn5AAPlrF8fjpUbmDxa0wXuBhdab+fhJZH8ZV+jjKD1QVEp3XnGOiBuKeoN0F0N+lH O2xQ== MIME-Version: 1.0 X-Received: by 10.69.25.69 with SMTP id io5mr76213866pbd.22.1395707320488; Mon, 24 Mar 2014 17:28:40 -0700 (PDT) In-Reply-To: References: <9daf0806-02de-4447-964c-c8f8953c23e5@googlegroups.com> <10101874-2995-4acd-9851-989603f052e3@googlegroups.com> <532d5bd9$0$29994$c3e8da3$5496439d@news.astraweb.com> <87ior3w740.fsf@elektro.pacujo.net> Date: Tue, 25 Mar 2014 11:28:40 +1100 Subject: Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list) 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: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1395707323 news.xs4all.nl 2860 [2001:888:2000:d::a6]:36691 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68921 On Tue, Mar 25, 2014 at 11:16 AM, Mark H Harris wrote: > On 3/24/14 7:11 PM, Chris Angelico wrote: >> >> On Tue, Mar 25, 2014 at 10:56 AM, Mark H Harris >> wrote: >>> >>> What is needed is the explicit closure "grab" recommended by ChrisA. >> >> >> Which does work. You do know why, right? > > > Sure. ... but again, that's not the point. The point is NOT can you explain > why it works, the point is that as a lambda construct it is NOT clear why it > works, and because the construct does not match what lambda users might > expect (naturally) there are *constant* questions about it. > > So, again, I'll restate that the community might consider (over time) > whether the confusion created by lambda in python is worth the time and > trouble to maintain the construct in the language. Is the value add worth > the cost of confusion. I don't think so; others are bound to disagree. Pure functional programming, from what I understand, doesn't *have* variables other than function arguments. So the way to implement "x = 1" is to call a subfunction with an argument of 1, which is referred to as x. (Am I right so far?) In that case, the default argument trick is exactly the right way to implement that in Python. ChrisA