Dan Rose <daniel.buch...@gmail.com> added the comment:

The general problem with infinite iterators is indeed a bigger issue and its 
resolution would probably resolve this issue too. With the examples you gave at 
least the user can ctrl-c to interrupt. Entering an infinite, *uninterruptible* 
loop is a consequence so bad that it deserves a guard rail.

> On May 25, 2019, at 11:48, Serhiy Storchaka <rep...@bugs.python.org> wrote:
> 
> 
> Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:
> 
> Adding the __contains__() method to the count iterator would not solve the 
> general problem with infinite iterators. For example with the following 
> expressions:
> 
>    -1 in filter(None, itertools.count())
>    -1 in map(float, itertools.count())
> 
> It is not worth to add a method just to handle a single case of misusing. You 
> should not use "in" with infinite iterators.
> 
> ----------
> nosy: +serhiy.storchaka
> 
> _______________________________________
> Python tracker <rep...@bugs.python.org>
> <https://bugs.python.org/issue37040>
> _______________________________________

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37040>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to