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

Jan Kaliszewski zuo at chopin.edu.pl
Sun Mar 27 15:11:49 CEST 2011


Ben Finney dixit (2011-03-27, 23:46):

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

Yeah, you're right. To less sleep...

But anyway, I'd prefer filter(is_none, iterable)
:)

*j




More information about the Python-ideas mailing list