Ron Adam wrote:
Is y a list of values sent to g? Excuse me if I'm a bit lost there. I haven't played around with the new generator features yet.
This relates to the discussion about my proposal for a 'yield from' statement. Part of it is that 'return x' in a generator will be equivalent to 'raise StopIteration(x)', with x becoming the value of the 'yield from' expression (or in this case the 'pass' expression).
Having the presence of yield to determine if they are a generator or not, seems a bit implicit to me. I'd much prefer a new keyword, 'defgen' or something like it
That argument was debated at great length and lost long ago, when generators were first invented. I don't think there's any chance of it being changed now.
I don't know that it would help anything much anyhow, since you also need to be aware that it's a generator every time you use it, and even if it's defined differently, that doesn't help at the call site. The only solution to that is naming conventions and/or documentation.