[Python-ideas] Membership of infinite iterators

Serhiy Storchaka storchaka at gmail.com
Tue Oct 17 05:19:26 EDT 2017

17.10.17 09:42, Nick Coghlan пише:
> On 17 October 2017 at 16:32, Nick Coghlan 
> <ncoghlan at gmail.com 
> <mailto:ncoghlan at gmail.com>> wrote:
>     So this sounds like a reasonable API UX improvement to me, but you'd
>     need to ensure that you don't inadvertently change the external
>     behaviour of *successful* containment tests.
> I should also note that there's another option here beyond just 
> returning "False": it would also be reasonable to raise an exception 
> like "RuntimeError('Attempted negative containment check on infinite 
> iterator')".

What about other operations with infinite iterators? min(count()), 
max(count()), all(count(1))? Do you want to implement special cases for 
all of them?

More information about the Python-ideas mailing list