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:

https://docs.python.org/3/library/inspect.html#inspect.isgeneratorfunction

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.

https://docs.python.org/3/glossary.html


-- 
Steven
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/7QBQTUN5WMB2VR2ISGC3FU2C7O6ELBAB/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to