Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40872
| From | Neil Cerutti <neilc@norwich.edu> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: itertools.filterfalse - what is it good for |
| Date | 2013-03-08 17:02 +0000 |
| Organization | Norwich University |
| Message-ID | <apujtvFjj6gU1@mid.individual.net> (permalink) |
| References | <mailman.3087.1362761126.2939.python-list@python.org> |
On 2013-03-08, Wolfgang Maier <wolfgang.maier@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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
itertools.filterfalse - what is it good for Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2013-03-08 16:45 +0000 Re: itertools.filterfalse - what is it good for Neil Cerutti <neilc@norwich.edu> - 2013-03-08 17:02 +0000 Re: itertools.filterfalse - what is it good for Miki Tebeka <miki.tebeka@gmail.com> - 2013-03-09 12:30 -0800 Re: itertools.filterfalse - what is it good for Miki Tebeka <miki.tebeka@gmail.com> - 2013-03-09 12:30 -0800
csiph-web