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: 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: References: Date: Sat, 17 Dec 2011 05:25:12 +1100 Subject: Re: Making the case for "typed" lists/iterators in python From: Chris Angelico 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On Sat, Dec 17, 2011 at 5:05 AM, Roy Smith wrote: > Most of this was TL:DNR, but I will admit I often wish for a better way > to log intermediate values. =A0For example, a common pattern in the code > I'm working with now is functions that end in: > > =A0 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: > > =A0 =A0temp =3D [Foo(x) for x in bunch_of_x_thingies] > =A0 =A0logger.debug(temp) > =A0 =A0return 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 =3D lambda func,arg: (func(arg),arg)[1] return tee(logger.debug,[Foo(x) for x in bunch_of_x_thingies]) ChrisA