Message343496
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>
> _______________________________________ |
|
Date |
User |
Action |
Args |
2019-05-25 17:30:58 | Dan Rose | set | recipients:
+ Dan Rose, rhettinger, martin.panter, serhiy.storchaka |
2019-05-25 17:30:58 | Dan Rose | link | issue37040 messages |
2019-05-25 17:30:58 | Dan Rose | create | |
|