On Thu, Nov 20, 2014 at 7:48 AM, MRAB <pyt...@mrabarnett.plus.com> wrote: > The PEP says """any generator that depends on an implicitly-raised > StopIteration to terminate it will have to be rewritten to either catch > that exception or use a for-loop""" > > Shouldn't that be "... explicitly-raised ...", because returning raises > StopIteration implicitly? ("raise StopIteration" is explicit)
The point here is primarily about some other function (maybe a next(iter), or maybe something else entirely) raising StopIteration. (If it explicitly raises StopIteration right there in the generator, it can be trivially converted into a return statement, anyway.) The return statement is an explicit indication that the generator should now return; permitting a StopIteration to bubble up through and out is the implicit option; but the 'plicitness' isn't necessarily obvious. ChrisA _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com