Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #95190
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Subject | Re: Iterators membership testing |
| Date | 2015-08-09 14:45 +0100 |
| References | <88256581-75d4-4f77-81f0-9e3e25baecbc@googlegroups.com> <CAPTjJmoibrvoxFt7o3XA+h_5ETTCS1b9uNUOhK=1UpRvo3PTpQ@mail.gmail.com> <20150809080917.2c87f22f@bigbox.christie.dr> <CAPTjJmo28ioMWiyqkR5B18M-0=oHyP3rx63EjCFCx13AZwNqSA@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.8.1439127948.3627.python-list@python.org> (permalink) |
On 09/08/2015 14:11, Chris Angelico wrote:
> On Sun, Aug 9, 2015 at 11:09 PM, Tim Chase <tim@thechases.com> wrote:
>> 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)
>
> Indeed it can, although I'm not sure whether it'd just have been
> another step in the explanation :) Whether or not that makes perfect
> sense depends on the reader.
>
> ChrisA
>
This one probably won't make make sense to most readers.
any("Australian batsmen scored any() runs recently?")
See also
http://www.cricketcountry.com/photos/photo-england-supporters-sell-hardly-used-australian-bats-314378
:)
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
Back to comp.lang.python | Previous | Next — Previous in thread | Next 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