On Fri, May 6, 2016 at 1:07 PM, Dan Sommers <d...@tombstonezero.net> wrote: > On Fri, 06 May 2016 02:46:22 +0000, Dan Sommers wrote: > >> Python 2.7.11+ (default, Apr 17 2016, 14:00:29) >> [GCC 5.3.1 20160409] on linux2 >> Type "help", "copyright", "credits" or "license" for more information. >> >>> filter(lambda x:x+1, [1, 2, 3, 4]) >> [1, 2, 3, 4] >> >> Python 3.5.1+ (default, Apr 17 2016, 16:14:06) >> [GCC 5.3.1 20160409] on linux >> Type "help", "copyright", "credits" or "license" for more information. >> >>> filter(lambda x:x+1, [1, 2, 3, 4]) >> <filter object at 0x7f26a9ef3320> > > Muphrey's Law strikes again. That lambda function is obviously a > leftover from a call to *map* rather than a call to *filter*, but thanks > everyone for not laughing and pointing.
Hey, maybe you wanted to filter out all the -1 results. Maybe you have a search function that returns zero-based offsets, or -1 for "not found". Seems reasonable! And "x+1" is way shorter than "x!=-1", which means by definition that it's better. ChrisA -- https://mail.python.org/mailman/listinfo/python-list