26 Mar
2009
26 Mar
'09
10:53 p.m.
Guido van Rossum wrote:
That +0 could turn into a +1 if there was a way to flag this as an error (at runtime), at least if the return is actually executed:
def g(): yield 42 return 43
for x in g(): print x # probably expected to print 42 and then 43
Perhaps the exception used in this case could be a different exception than StopIteration?
Would checking that the value is None be sufficient? Or do you want to distinguish between 'return' and 'return None'? That would feel rather strange to me. I'm inclined to regard this as an unnecessary complication. People are already trained to think of 'return' and 'yield' as quite different things. I don't know why they would suddenly start using 'return' when they mean 'yield'. -- Greg