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: 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: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=75.82.8.111; posting-account=uo-8fwoAAACKsFzFX78JHudx1V7WDXZ0 References: 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 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: 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 > 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)