On 2013-03-08, Wolfgang Maier <wolfgang.ma...@biologie.uni-freiburg.de> wrote: > Dear all, > can anybody point out a situation where you really need > itertools.filterfalse() ? So far, I couldn't think of a case > where you couldn't replace it with a generator expression/if > combination. e.g., > > a=filterfalse(lambda x: x%2, range(1,101)) > b=(i for i in range(1,101) if not i % 2) > > do not return the same object type, but otherwise are achieving > the same thing. What am I missing here? For sure filterfalse > exists for a reason?
It must exist for reasons of convenience and efficiency only. It can trivially be replaced by filter in all cases (at least in Python 3), but it saves you from a possibly slow extra function indirection, and also from needing to define one at all. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list