Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #58997

Re: my favorite line of py code so far

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 <rosuav@gmail.com>
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 <dae981ac-14e7-47c8-89ed-a5ad21e956ca@googlegroups.com>
References <fbbabb45-f0e3-4e7f-968f-9822607c450a@googlegroups.com> <dae981ac-14e7-47c8-89ed-a5ad21e956ca@googlegroups.com>
Date Sun, 10 Nov 2013 21:23:46 +1100
Subject Re: my favorite line of py code so far
From Chris Angelico <rosuav@gmail.com>
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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2328.1384079035.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Sun, Nov 10, 2013 at 7:57 PM, Peter Cacioppi
<peter.cacioppi@gmail.com> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

my favorite line of py code so far Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-11-08 14:22 -0800
  Re: my favorite line of py code so far Chris Angelico <rosuav@gmail.com> - 2013-11-09 09:32 +1100
  Re: my favorite line of py code so far Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-11-08 14:43 -0800
  Re: my favorite line of py code so far Peter Otten <__peter__@web.de> - 2013-11-09 08:12 +0100
  Re: my favorite line of py code so far Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-11-09 01:23 -0800
    Re: my favorite line of py code so far Chris Angelico <rosuav@gmail.com> - 2013-11-09 20:28 +1100
    Re: my favorite line of py code so far Paul Rubin <no.email@nospam.invalid> - 2013-11-09 01:49 -0800
    Re: my favorite line of py code so far Peter Otten <__peter__@web.de> - 2013-11-09 12:49 +0100
    Re: my favorite line of py code so far Stefan Behnel <stefan_ml@behnel.de> - 2013-11-09 13:41 +0100
    Re: my favorite line of py code so far Chris Angelico <rosuav@gmail.com> - 2013-11-09 23:45 +1100
    Re: my favorite line of py code so far Peter Otten <__peter__@web.de> - 2013-11-09 14:49 +0100
  Re: my favorite line of py code so far Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-11-10 00:57 -0800
    Re: my favorite line of py code so far Chris Angelico <rosuav@gmail.com> - 2013-11-10 21:23 +1100
  Re: my favorite line of py code so far Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-11-10 00:59 -0800
  Re: my favorite line of py code so far Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-11-10 16:00 -0800

csiph-web