Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #95214
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <tim@thechases.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; 'nicely': 0.07; 'val': 0.07; 'cc:addr:python-list': 0.09; 'obj': 0.09; ':-)': 0.12; 'def': 0.13; 'interpreter': 0.15; '-tkc': 0.16; 'from:name:tim chase': 0.16; 'iterator': 0.16; 'wrote:': 0.16; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'this:': 0.23; 'written': 0.24; 'header:In-Reply-To:1': 0.24; 'chris': 0.26; 'right.': 0.27; 'code': 0.30; 'becomes': 0.30; 'initially': 0.30; 'handle': 0.34; 'false': 0.35; 'something': 0.35; 'subject:: ': 0.37; 'received:10': 0.37; 'charset:us-ascii': 0.37; 'easy': 0.60; 'received:50': 0.66; 'subject:membership': 0.91 |
| X-Sender-Id | wwwh|x-authuser|tim@thechases.com |
| X-Sender-Id | wwwh|x-authuser|tim@thechases.com |
| X-MC-Relay | Neutral |
| X-MailChannels-SenderId | wwwh|x-authuser|tim@thechases.com |
| X-MailChannels-Auth-Id | wwwh |
| X-MC-Loop-Signature | 1439125768960:3661818386 |
| X-MC-Ingress-Time | 1439125768959 |
| Date | Sun, 9 Aug 2015 08:09:17 -0500 |
| From | Tim Chase <tim@thechases.com> |
| To | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Subject | Re: Iterators membership testing |
| In-Reply-To | <CAPTjJmoibrvoxFt7o3XA+h_5ETTCS1b9uNUOhK=1UpRvo3PTpQ@mail.gmail.com> |
| References | <88256581-75d4-4f77-81f0-9e3e25baecbc@googlegroups.com> <CAPTjJmoibrvoxFt7o3XA+h_5ETTCS1b9uNUOhK=1UpRvo3PTpQ@mail.gmail.com> |
| X-Mailer | Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 7bit |
| X-AuthUser | tim@thechases.com |
| X-Mailman-Approved-At | Mon, 10 Aug 2015 12:00:19 +0200 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.34.1439200820.3627.python-list@python.org> (permalink) |
| Lines | 22 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1439200820 news.xs4all.nl 2901 [2001:888:2000:d::a6]:38320 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:95214 |
Show key headers only | View raw
On 2015-08-09 19:24, Chris Angelico wrote: > That's exactly right. The only way for the interpreter to handle > 'in' on an iterator is something like this: > > def contains(iter, obj): > for val in iter: > if val == obj: return True > return False Which can nicely be written as any(i == obj for obj in iter) The addition of any/all initially struck me as a "why?! this is so easy to write in-line" moment, only to find myself using them all() the time. :-) The code-intention becomes so much clearer. Even back-ported them to 2.4 code that I maintain. -tkc
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Iterators membership testing Pierre Quentel <pierre.quentel@gmail.com> - 2015-08-09 02:06 -0700
Re: Iterators membership testing Chris Angelico <rosuav@gmail.com> - 2015-08-09 19:24 +1000
Re: Iterators membership testing Pierre Quentel <pierre.quentel@gmail.com> - 2015-08-09 02:55 -0700
Re: Iterators membership testing Chris Angelico <rosuav@gmail.com> - 2015-08-09 20:13 +1000
Re: Iterators membership testing Pierre Quentel <pierre.quentel@gmail.com> - 2015-08-09 04:00 -0700
Re: Iterators membership testing Chris Angelico <rosuav@gmail.com> - 2015-08-09 21:10 +1000
Re: Iterators membership testing Laura Creighton <lac@openend.se> - 2015-08-09 13:30 +0200
Re: Iterators membership testing Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-08-09 14:49 +0100
Re: Iterators membership testing Chris Angelico <rosuav@gmail.com> - 2015-08-09 23:11 +1000
Re: Iterators membership testing Tim Chase <python.list@tim.thechases.com> - 2015-08-09 08:09 -0500
Re: Iterators membership testing Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-08-09 14:45 +0100
Re: Iterators membership testing Tim Chase <tim@thechases.com> - 2015-08-09 08:09 -0500
csiph-web