[Python-ideas] Two small functional-style-related improvements

Oleg Broytman phd at phdru.name
Sun Mar 27 14:02:56 CEST 2011

On Sun, Mar 27, 2011 at 01:53:26PM +0200, Jan Kaliszewski wrote:
> Which one of the following do you prefer?
> * filter((lambda x: x is None), iterable)
> * filter(functools.partial(operator.is_, None), iterable)
> * filter(None, (x is None for x in iterable))
> * filter(operator.is_none, iterable)

   I prefer

[x for x in iterable if x is not None]

     Oleg Broytman            http://phdru.name/            phd at phdru.name
           Programmers don't die, they just GOSUB without RETURN.

More information about the Python-ideas mailing list