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


Groups > comp.lang.python > #17373

Re: Making the case for "typed" lists/iterators in python

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.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.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'debug': 0.03; 'transform': 0.07; 'admit': 0.09; 'subject:python': 0.10; 'am,': 0.12; 'received:209.85.210.174': 0.13; 'received:mail- iy0-f174.google.com': 0.13; 'intermediate': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'lambda': 0.16; 'roy': 0.16; 'subject:case': 0.16; 'temp': 0.16; '\xa0for': 0.16; 'wrote:': 0.18; 'dec': 0.22; 'header:In-Reply- To:1': 0.22; 'values.': 0.23; 'sat,': 0.25; 'code': 0.25; "i'm": 0.26; 'subject:" ': 0.28; 'message-id:@mail.gmail.com': 0.28; 'explicit': 0.29; 'skip:b 20': 0.29; 'pattern': 0.30; 'in:': 0.32; 'to:addr:python-list': 0.34; '17,': 0.34; 'something': 0.35; 'subject:/': 0.35; 'subject:lists': 0.36; 'example,': 0.37; 'convenient': 0.37; 'pull': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'skip:\xa0 10': 0.39; 'goes': 0.39; 'received:209': 0.40; 'to:addr:python.org': 0.40; '2011': 0.61; 'wish': 0.70; 'subject:Making': 0.84; 'temporary.': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=kl1nfW8/tqfcBX893QalvwNqk1P/wPID8D+Wz2Uqisc=; b=vENbjkDURVBshCofnpvrcQtsar8Qa4KUc1yaQhhYos5kWpywz2cBZFM0FbBJmlThwz k+Ems14d6kxWx2iZ6Aalf4DCE3XRs4PmM76aQzOYXOwCd4ZF8GAyMfHufNHH9loUZxRx 0qsAvO3MRnMBPqTj03gU8YltmX7BkN/uq5czw=
MIME-Version 1.0
In-Reply-To <roy-CE17C0.13053616122011@news.panix.com>
References <mailman.3739.1324057724.27778.python-list@python.org> <roy-CE17C0.13053616122011@news.panix.com>
Date Sat, 17 Dec 2011 05:25:12 +1100
Subject Re: Making the case for "typed" lists/iterators in python
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3745.1324059914.27778.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1324059914 news.xs4all.nl 6869 [2001:888:2000:d::a6]:52209
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:17373

Show key headers only | View raw


On Sat, Dec 17, 2011 at 5:05 AM, Roy Smith <roy@panix.com> wrote:
> Most of this was TL:DNR, but I will admit I often wish for a better way
> to log intermediate values.  For example, a common pattern in the code
> I'm working with now is functions that end in:
>
>   return [Foo(x) for x in bunch_of_x_thingies]
>
> When something goes amiss and I want to debug the problem, I often
> transform that into:
>
>    temp = [Foo(x) for x in bunch_of_x_thingies]
>    logger.debug(temp)
>    return temp
>
> It would be convenient to be able to get at and log the intermediate
> value without having to pull it out to an explicit temporary.

tee = lambda func,arg: (func(arg),arg)[1]

return tee(logger.debug,[Foo(x) for x in bunch_of_x_thingies])

ChrisA

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


Thread

Making the case for "typed" lists/iterators in python Nathan Rice <nathan.alexander.rice@gmail.com> - 2011-12-16 12:48 -0500
  Re: Making the case for "typed" lists/iterators in python Roy Smith <roy@panix.com> - 2011-12-16 13:05 -0500
    Re: Making the case for "typed" lists/iterators in python Chris Angelico <rosuav@gmail.com> - 2011-12-17 05:25 +1100
    Re: Making the case for "typed" lists/iterators in python Arnaud Delobelle <arnodel@gmail.com> - 2011-12-16 18:38 +0000
    Re: Making the case for "typed" lists/iterators in python Chris Angelico <rosuav@gmail.com> - 2011-12-17 05:43 +1100
      Re: Making the case for "typed" lists/iterators in python Mel Wilson <mwilson@the-wire.com> - 2011-12-16 15:14 -0500
    Re: Making the case for "typed" lists/iterators in python Ben Finney <ben+python@benfinney.id.au> - 2011-12-17 07:17 +1100
    Re: Making the case for "typed" lists/iterators in python Terry Reedy <tjreedy@udel.edu> - 2011-12-16 17:21 -0500
  Re: Making the case for "typed" lists/iterators in python Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2011-12-19 14:16 +0100
    Re: Making the case for "typed" lists/iterators in python Nathan Rice <nathan.alexander.rice@gmail.com> - 2011-12-19 10:56 -0500

csiph-web