March 27, 2009
5:25 a.m.
On Thu, Mar 26, 2009 at 4:19 PM, P.J. Eby wrote:
What I don't like is the confusion of adding "return values" to generators, at least using the 'return' statement.
At Fri Mar 27 04:39:48 CET 2009, Guido van Rossum replied:
I'm +1 on "yield from" and +0 on return values in generators.
def g(): yield 42 return 43
for x in g(): print x # probably expected to print 42 and then 43
I still don't see why it needs to be a return statement. Why not make the intent of g explicit, by writing either def g(): yield 42 yield 43 or def g(): yield 42 raise StopIteration(43) -jJ