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

Chris Angelico rosuav at gmail.com
Fri Nov 21 17:08:38 CET 2014


On Sat, Nov 22, 2014 at 2:58 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> Since zip() is documented as
> halting on the shorter argument, it can't raise an exception. So what
> other options are there apart from silently consuming the value?

Sure, it's documented as doing that. But imagine something that isn't
a well-known function - all you have is someone writing a generator
that calls next() in multiple places. Is it obvious that it it'll
silently terminate as soon as any one of those iterators is exhausted?
In many cases, an exception (probably ValueError?) would be the most
obvious response.

ChrisA


More information about the Python-Dev mailing list