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

Ben Finney ben+python at benfinney.id.au
Sun Mar 27 14:46:13 CEST 2011


Jan Kaliszewski <zuo at chopin.edu.pl> writes:

> 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)

(x for x in iterable if x is None)

-- 
 \             “The Way to see by Faith is to shut the Eye of Reason.” |
  `\                                                —Benjamin Franklin |
_o__)                                                                  |
Ben Finney




More information about the Python-ideas mailing list