Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ben Finney Newsgroups: comp.lang.python Subject: Re: Fear and suspicion of lambdas, was Re: Meta decorator with parameters, defined in explicit functions Date: Sat, 02 Jul 2016 11:52:07 +1000 Lines: 35 Message-ID: References: <85mvm5vrbw.fsf@benfinney.id.au> <0690f476-95ad-4dec-87e5-42ecee07fdcd@googlegroups.com> <87poqx96ul.fsf@handshake.de> <87bn2h85rn.fsf@bsb.me.uk> <8537nsvmbc.fsf@benfinney.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de sPo4Z93o/oajooVRz0B/gA/6lauVePqkZLVi8I8TVhMA== Cancel-Lock: sha1:qQvdkRfHk8X4VdoK8qLNgj3vgo8= Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.070 X-Spam-Evidence: '*H*': 0.86; '*S*': 0.01; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.10; 'lambda': 0.16; 'parts,': 0.16; 'rather,': 0.16; 'readable': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'subject:parameters': 0.16; 'nested': 0.18; 'accepting': 0.18; 'function,': 0.22; 'seems': 0.23; 'component': 0.23; 'header:User-Agent:1': 0.26; 'header:X -Complaints-To:1': 0.26; 'least': 0.27; 'idea': 0.28; 'job:': 0.29; 'motivation': 0.29; 'thread,': 0.29; 'code:': 0.29; "i'm": 0.30; 'that.': 0.30; 'creating': 0.30; 'statement': 0.32; 'functions.': 0.35; 'quite': 0.35; 'but': 0.36; 'should': 0.36; 'there': 0.36; 'tool': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'names': 0.38; 'to:addr:python.org': 0.40; 'subject:with': 0.40; 'replying': 0.61; 'reach': 0.61; 'here.': 0.62; 'making': 0.62; 'more': 0.63; "they're": 0.66; '_o__)': 0.84; 'for;': 0.84; 'premise': 0.84; 'received:125': 0.84; 'suspicion': 0.84; "they'd": 0.84; 'widespread': 0.91; 'thing,': 0.93; 'hong': 0.96; 'kong': 0.96 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: jigong.madmonks.org X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <8537nsvmbc.fsf@benfinney.id.au> X-Mailman-Original-References: <85mvm5vrbw.fsf@benfinney.id.au> <0690f476-95ad-4dec-87e5-42ecee07fdcd@googlegroups.com> <87poqx96ul.fsf@handshake.de> <87bn2h85rn.fsf@bsb.me.uk> Xref: csiph.com comp.lang.python:110926 Ben Bacarisse writes: > By replying I'm not accepting the premise -- I have no idea if there > is widespread fear and suspicion of lambdas among Python users but it > seems unlikely. I can testify, as the person who started this thread, that there is no fear or suspicion of lambda here. I use it quite frequently without qualm for creating self-explanatory functions that need no name. Rather, the motivation was that a complex thing, with many moving parts, has an unexplained implementation: a nested set of functions without names to explain their part in the pattern. That these are then immediately bound to a name, to me defeats the purpose of using lambda in the first place. If you want a named function, lambda is not the tool to reach for; we have the ‘def’ statement for that. But by using ‘lambda’ the author avoided one of the more important parts of publishing the code: making it readable and self-explanatory. If they'd chosen a name for each function, that would at least have prompted them to explain what they're doing. So ‘lambda’ is great, and I use it without worry for creating simple self-explanatory nameless functions. But it's not the right tool for this job: This is not self-explanatory, and the component functions should not be nameless. -- \ “It is forbidden to steal hotel towels. Please if you are not | `\ person to do such is please not to read notice.” —hotel, | _o__) Kowloon, Hong Kong | Ben Finney