<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Aug 8, 2017 at 10:06 PM, Nick Coghlan <span dir="ltr"><<a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 8 August 2017 at 09:06, Chris Barker <<a href="mailto:chris.barker@noaa.gov">chris.barker@noaa.gov</a>> wrote:<br>
> It would be nice to have an easier access to an "slice iterator" though --<br>
> one of these days I may write up a proposal for that.<br>
<br>
</span>An idea I've occasionally toyed with [1] is some kind of "iterview"<br>
that wraps around an arbitrary iterable and produces lazy itertools<br>
based results rather than immediate views or copies.<br>
<br>
However, my experience is also that folks are *really* accustomed to<br>
syntactic operations on containers producing either full live views<br>
(e.g. memoryview or numpy slices, range as a dynamically computed<br>
container), or actual copies (builtin container types). Having them<br>
produce consumable iterators instead then gets confusing due to the<br>
number of operations that will implicitly consume them (including<br>
simple "x in y" checks).<br></blockquote><div><br></div><div>I agree -- which is why I"m thinking only adding a simple "iterable slice", rather than changing the overall behavior of the container. It would be quite clear what you are asking for.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Right now, getting the "terminate when false" behaviour requires the<br>
use of takewhile:<br></blockquote><div><br></div><div>I can't recall the use case(s) at the moment, but I have definitely wanted a way to break out of a comprehension -- and not always with infinite iterators.</div><div><br></div><div>After all, we have "break" in both for and while loops, so clearly there is the use case...</div><div><br></div><div>If someone comes up with a clean and not confusing (and general purpose) syntax, I think it would be very useful.</div><div><br></div><div>-CHB</div><div><br></div></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R (206) 526-6959 voice<br>7600 Sand Point Way NE (206) 526-6329 fax<br>Seattle, WA 98115 (206) 526-6317 main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div></div>