On Thu, Nov 20, 2014 at 3:45 AM, Nick Coghlan <ncogh...@gmail.com> wrote: > The part I found most compelling was when you pointed out that in the > special method implementations, the normal return path was always spelled > with "return", while the "value missing" result was indicated with a special > kind of exception (StopIteration, AttributeError, IndexError or KeyError), > and then any other exception was consider unexpected. > > Generators add the third notion of being able to suspend execution via > "yield", which then left them with two different ways of spelling > termination inside the frame: "return" OR "raise StopIteration". The second > spelling ("raise StopIteration") is then inherently surprising, as it's > entirely redundant, *except* in that it allows you to effectively have a > "hidden return" in a generator frame that can't be done anywhere else.
(The above was said on -ideas, but discussion is now moving to -dev, so I hope it's okay to send the response there.) Added a paragraph to the PEP draft: https://github.com/Rosuav/GenStopIter/commit/695961 Should today's date be added to the Post-History? 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