Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.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.026 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'argument': 0.05; 'importing': 0.05; 'subject:code': 0.07; 'function,': 0.09; 'doing,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'inclined': 0.16; 'lambda': 0.16; 'wrote:': 0.18; 'module': 0.19; 'this?': 0.23; 'tells': 0.24; 'fine': 0.24; 'equivalent': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'message-id:@mail.gmail.com': 0.30; 'along': 0.30; 'code': 0.31; 'lines': 0.31; 'probably': 0.32; 'bugs': 0.33; 'sense': 0.34; "i'd": 0.34; 'could': 0.34; 'problem': 0.35; "can't": 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'doing': 0.36; 'mapping': 0.38; 'nov': 0.38; 'to:addr:python- list': 0.38; 'pm,': 0.38; 'though,': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'skip:u 10': 0.60; "you're": 0.61; 'name': 0.63; 'map': 0.64; 'nobody': 0.68; 'imagine': 0.93; '2013': 0.98 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:to :content-type; bh=3AQzAk25kQt2GSeiQ+CqoE1V2HBmIU6NcbBvSRKL/c4=; b=XfMBHoUbEyrrvX9PvnXp9QxyG53tMRwi0UQz5luXprp1OFJg4avkNEMz1t3IpsdeZm CvZHEoTw8/nDRRwNZyBdNH61GPaxOglQzxpMGKHe89qXyzS4WAl7KG1JrXNBfQzBViq2 NVwUn7u1eJIo2ua0AUd+Vknwty0LfaaVBjX3lvjckfMrOdhvzouA+aHPxrw67yy6tAO7 +ENRQq4pdxMEJcB5L/PGYbAarbrdD5CgcMIBdxUmxs/2xDqGDfJaJ7lSn8D7HB5EJmTs +SNm+qu8L3gRL/34GU0fC/eoYK7VOn/FRNM2Zx0Q9M9aJasAYzvfuioogOW9S8/loNsd SXjg== MIME-Version: 1.0 X-Received: by 10.68.217.129 with SMTP id oy1mr24344492pbc.23.1384079026545; Sun, 10 Nov 2013 02:23:46 -0800 (PST) In-Reply-To: References: Date: Sun, 10 Nov 2013 21:23:46 +1100 Subject: Re: my favorite line of py code so far 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.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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1384079035 news.xs4all.nl 15925 [2001:888:2000:d::a6]:48151 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:58997 On Sun, Nov 10, 2013 at 7:57 PM, Peter Cacioppi wrote: > Chris said : > > "I think map is fine if you can use a named function, but if you can't > come up with a descriptive name for what you're doing, a comprehension > is probably better (as it'll have the code right there). Mapping _ > across everything tells you nothing about what it's actually doing" > > How about this? I put the following in my catchall_utility.py module > > # the oneArg combinator takes a multi-argument calleable > # and returns the equivalent single argument calleable > oneArg = lambda c: lambda x : c(*x) Now it has a name, so I could imagine you importing it into modules and using it usefully. I'd be inclined to call it something along the lines of "unpacked" but that's just bikeshedding. > ... I find that I write fewer bugs when I use idioms that resonate. Absolutely! The unfortunate truth, though, is that idioms that resonate with you _and nobody else_ are just as big a problem as bugs, because they're unmaintainable. So hopefully what you're doing will make sense to other people too! ChrisA