<div dir="ltr"><div class="gmail_default" style="font-family:monospace,monospace"><span style="font-family:arial,sans-serif">On Tue, Oct 17, 2017 at 5:26 PM, Serhiy Storchaka </span><span dir="ltr" style="font-family:arial,sans-serif"><<a href="mailto:storchaka@gmail.com" target="_blank">storchaka@gmail.com</a>></span><span style="font-family:arial,sans-serif"> wrote:</span><br></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">17.10.17 17:06, Nick Coghlan пише:<span class=""><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Keep in mind we're not talking about a regular loop you can break out of with Ctrl-C here - we're talking about a tight loop inside the interpreter internals that leads to having to kill the whole host process just to get out of it.<br>
</blockquote>
<br></span>
And this is the root of the issue. Just let more tight loops be interruptible with Ctrl-C, and this will fix the more general issue.<div class="HOEnZb"><div class="h5"><br></div></div></blockquote><div><br></div><div class="gmail_default" style="font-family:monospace,monospace">Not being able to interrupt something with Ctrl-C in the repl or with the interrupt command in Jupyter notebooks is definitely a thing I sometimes encounter. A pity I don't remember when it happens, because I usually forget it very soon after I've restarted the kernel and continued working. But my guess is it's usually not because of an infinite iterator.</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">Regarding what the OP might have been after, and just for some wild brainstorming based on true stories: In some sense, x in y should always have an answer, even if it may be expensive to compute. Currently, it's possible to implement "lazy truth values" which compute the bool value lazily when .__bool__() is called. Until you call bool(..) on it, it would just be Maybe, and then after the call, you'd actually have True or False. In many cases it can even be enough to know if something is Maybe true. Also, if you do something like any(*truth_values), then you could skip the Maybe ones on the first pass, because if you find one that's plain True, you already have the answer. <br></div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">Regarding `x in y`, where y is an infinite iterable without well defined contents, that would return an instance of MaybeType, but .__bool__() would raise an exception.</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">––Koos</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div></div><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">+ Koos Zevenhoven + <a href="http://twitter.com/k7hoven" target="_blank">http://twitter.com/k7hoven</a> +</div>
</div></div>