This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Dan Rose
Recipients Dan Rose, martin.panter, rhettinger, serhiy.storchaka
Date 2019-05-25.17:30:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <9514C497-7BAF-4A56-B48A-4AD5139423CE@gmail.com>
In-reply-to <1558802882.8.0.814699082128.issue37040@roundup.psfhosted.org>
Content
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 <report@bugs.python.org> wrote:
> 
> 
> Serhiy Storchaka <storchaka+cpython@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 <report@bugs.python.org>
> <https://bugs.python.org/issue37040>
> _______________________________________
History
Date User Action Args
2019-05-25 17:30:58Dan Rosesetrecipients: + Dan Rose, rhettinger, martin.panter, serhiy.storchaka
2019-05-25 17:30:58Dan Roselinkissue37040 messages
2019-05-25 17:30:58Dan Rosecreate