Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #17373
| References | <mailman.3739.1324057724.27778.python-list@python.org> <roy-CE17C0.13053616122011@news.panix.com> |
|---|---|
| Date | 2011-12-17 05:25 +1100 |
| Subject | Re: Making the case for "typed" lists/iterators in python |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3745.1324059914.27778.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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