Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'remind': 0.05; 'subject:skip:c 10': 0.07; 'python': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'retained': 0.09; 'underlying': 0.09; 'library': 0.15; '238': 0.16; 'kern': 0.16; 'message- id:@dough.gmane.org': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'syntax,': 0.16; 'threads': 0.16; 'wrote:': 0.17; 'library,': 0.17; 'tests': 0.18; 'code,': 0.18; 'code.': 0.20; 'explicit': 0.22; 'interpret': 0.22; 'programming': 0.23; 'third-party': 0.23; "haven't": 0.23; 'header :In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; "doesn't": 0.28; 'header:X-Complaints-To:1': 0.28; 'lines': 0.28; 'subject:list': 0.28; '(unless': 0.29; 'function': 0.30; 'to:addr :python-list': 0.33; 'robert': 0.35; 'so,': 0.35; 'pm,': 0.35; "won't": 0.35; 'add': 0.36; 'received:org': 0.36; 'really': 0.36; 'modules': 0.36; 'two': 0.37; 'uses': 0.37; 'why': 0.37; 'rather': 0.37; 'subject:: ': 0.38; 'unit': 0.38; 'to:addr:python.org': 0.39; 'space': 0.39; 'header:Received:5': 0.40; 'john': 0.60; 'world': 0.63; 'our': 0.65; 'believe': 0.69; 'adhere': 0.84; 'drawer': 0.84; 'eco': 0.84; 'forced': 0.84; 'terrible': 0.84; 'subject:funny': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Robert Kern Subject: Re: lambda in list comprehension acting funny Date: Thu, 12 Jul 2012 10:06:53 +0100 References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 213.1.240.227 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 In-Reply-To: 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: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1342084030 news.xs4all.nl 6902 [2001:888:2000:d::a6]:57429 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25206 On 7/11/12 9:21 PM, John Ladasky wrote: > Exactly. It's threads like these which remind me why I never use lambda. I would rather give a function an explicit name and adhere to the familiar Python syntax, despite the two extra lines of code. I don't even like the name "lambda". It doesn't tell you what it is (unless you're John McCarthy), a function that you won't re-use and so you don't really need to give it a persistent name. > > I haven't seen any lambdas in any Python library code, or in any of the third-party modules I use (numpy, matplotlib, Biopython). Do they exist? Because I have not been forced to do so, I haven't retained a space in the top drawer of my programming brain for lambda. I count 162 uses in the Python standard library, 69 uses in numpy, 108 in matplotlib, and 238 uses in Biopython. Adding in the unit tests for each would add significantly to those counts. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco