Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40974
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <miki.tebeka@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; '(python': 0.05; 'removes': 0.05; 'parameter': 0.07; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; 'language': 0.14; '3):': 0.16; 'from:addr:miki.tebeka': 0.16; 'from:name:miki tebeka': 0.16; 'cc:2**0': 0.23; 'example': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; '(such': 0.27; 'subject:what': 0.29; 'function': 0.30; 'point': 0.31; 'anybody': 0.32; 'function.': 0.33; 'another': 0.33; 'received:google.com': 0.34; 'filter': 0.35; 'sometimes': 0.35; 'received:209.85': 0.35; 'really': 0.36; 'skip:p 20': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'things': 0.38; 'easily': 0.39; 'where': 0.40; 'situation': 0.62; 'subject:good': 0.84 |
| X-Received | by 10.50.163.41 with SMTP id yf9mr383698igb.3.1362861012495; Sat, 09 Mar 2013 12:30:12 -0800 (PST) |
| Newsgroups | comp.lang.python |
| Date | Sat, 9 Mar 2013 12:30:11 -0800 (PST) |
| In-Reply-To | <mailman.3087.1362761126.2939.python-list@python.org> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=75.82.8.111; posting-account=uo-8fwoAAACKsFzFX78JHudx1V7WDXZ0 |
| References | <mailman.3087.1362761126.2939.python-list@python.org> |
| User-Agent | G2/1.0 |
| X-Google-Web-Client | true |
| X-Google-IP | 75.82.8.111 |
| MIME-Version | 1.0 |
| Subject | Re: itertools.filterfalse - what is it good for |
| From | Miki Tebeka <miki.tebeka@gmail.com> |
| To | comp.lang.python@googlegroups.com |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Message-ID | <mailman.3139.1362861020.2939.python-list@python.org> (permalink) |
| Lines | 9 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1362861020 news.xs4all.nl 6934 [2001:888:2000:d::a6]:54104 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:40974 |
Show key headers only | View raw
> can anybody point out a situation where you really need itertools.filterfalse() ?
Sometimes you get the predicate as a parameter to another function. This way if you want to filter out things you can easily do it. Other language (such as Clojure) have a "complement" function that removes the need of filterfalse.
For example (Python 3):
def percent_spam(is_spam, documents):
n_spam = sum(1 for _ in filter(is_spam, documents))
n_ham = sum(1 for _ in filterfalse(is_spam, documents))
return float(n_spam) / (n_ham + n_spam)
Back to comp.lang.python | Previous | Next — Previous 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