
Feb. 19, 2009
4:28 p.m.
Greg Ewing <greg.ewing@...> writes:
Use of StopIteration to return values -------------------------------------
Why not a dedicated exception (e.g. GeneratorReturn) instead? Two advantages to doing so: * people mistakingly doing a "for" loop over such a generator would be reminded that they are missing something (the return value) * you could take advantage of existing iterator-consuming features (e.g. "yield from map(str, innergenerator())"), since they would just forward the exception instead of silencing it Regards Antoine.