Re: [Python-Dev] PEP 479: Change StopIteration handling inside generators

2014年11月21日 05:55:44 -0800

On Sat, Nov 22, 2014 at 12:47 AM, Raymond Hettinger
<[email protected]> wrote:
> Also, the proposal breaks a reasonably useful pattern of calling
> next(subiterator) inside a generator and letting the generator terminate
> when the data stream ends. Here is an example that I have taught for
> years:
>
> def izip(iterable1, iterable2):
> it1 = iter(iterable1)
> it2 = iter(iterable2)
> while True:
> v1 = next(it1)
> v2 = next(it2)
> yield v1, v2
Is it obvious to every user that this will consume an element from
it1, then silently terminate if it2 no longer has any content?
ChrisA
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to