On Mon, May 11, 2020 at 02:37:15PM +0900, Stephen J. Turnbull wrote:
I think part of the problem is that people rarely see explicit iterator objects in the wild. Most of the time we encounter iterator objects only implicitly. Nomenclature *is* a problem (I still don't know what a "generator" is: a function that contains "yield" in its def, or the result of invoking such a function),
Strictly speaking, a function containing yield is a "generator function", the object it returns is a "generator iterator", or just generator.
Analogy: "a float" is the object returned by the `float()` function, not the function itself.
People are often sloppy in their terminology, but the inspect module makes it clear:
Alas, the glossary is itself a bit sloppy: you have to read it with care to see it talks about *generator functions* and *generator iterators*. The entries for async generators are better.