Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '(especially': 0.07; 'class,': 0.07; 'parameter': 0.07; 'predefined': 0.07; 'rewrite': 0.07; 'subject:skip:c 10': 0.07; 'python': 0.09; 'buttons': 0.09; 'callback': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; '[and': 0.16; 'calculator': 0.16; 'class:': 0.16; 'lambda': 0.16; 'lisp': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'wed,': 0.16; 'math': 0.20; 'community.': 0.20; 'define': 0.20; 'equivalent': 0.20; 'assignment': 0.22; 'simpler': 0.22; "i've": 0.23; 'separate': 0.27; 'c++': 0.27; 'header:X-Complaints- To:1': 0.28; 'subject:list': 0.28; 'class': 0.29; 'classes': 0.30; 'basic': 0.30; 'function': 0.30; 'code': 0.31; 'implement': 0.32; 'could': 0.32; 'defining': 0.33; 'url:home': 0.33; 'to:addr :python-list': 0.33; 'data,': 0.35; 'received:org': 0.36; 'but': 0.36; 'scientific': 0.36; 'useful': 0.36; 'charset:us-ascii': 0.36; 'turn': 0.36; 'one,': 0.37; 'does': 0.37; 'being': 0.37; 'why': 0.37; 'rather': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'nothing': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'john': 0.60; 'containing': 0.61; 'button.': 0.65; 'jul': 0.65; 'treat': 0.65; 'presented': 0.72; 'archaic': 0.84; 'dennis': 0.91; 'received:108': 0.91; 'subject:funny': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: lambda in list comprehension acting funny Date: Wed, 11 Jul 2012 21:05:30 -0400 Organization: > Bestiaria Support Staff < References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-108-73-117-76.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: YES 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: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1342055140 news.xs4all.nl 6960 [2001:888:2000:d::a6]:35535 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25186 On Wed, 11 Jul 2012 13:21:34 -0700 (PDT), John Ladasky declaimed the following in gmane.comp.python.general: > I know the historical reason that Python ended up with lambda, it was requested by people in the Lisp community. While I appreciate some of the Lisp-like features which did find their way into Python (especially being able to treat code as data, and functions as objects), I've found that lambda does nothing for me. It can be useful when defining callbacks for GUIs that need a predefined argument... eg; a calculator application: 10 buttons for 0-9. Why define 10 separate callbacks when you only need one callback with a parameter containing the numeric value for the button. lambda x=#: number_button_callback(x) where # is the (integral) value of the specific button. {non sequitur: I still recall my archaic C++ class with the OOAD assignment of designing said calculator -- we never had to implement one, just design the basic classes/methods/attributes [on 3x5 cards] for a four-banger. I managed to persuade the team I was on that an RPN calculator would be simpler to (potentially) implement... And THEN persuaded them to NOT use the equivalent of an ALU class, but to put the math work into each operation button... Justification when presented to class: one could turn that four-banger into a scientific [or financial] calculator by just adding classes for the additional function buttons [and of course, buttons on screen] rather than having to rewrite an "ALU" class to understand all functions.} -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/