generator/coroutine terminology

Chris Angelico rosuav at gmail.com
Sat Mar 14 11:56:54 EDT 2015


On Sun, Mar 15, 2015 at 2:29 AM, Rustom Mody <rustompmody at gmail.com> wrote:
> However a "generator function" is a weird sort of function (at best).
> Not regarding it as a function is IMO more reasonable.

But it *is* a function. You call it, possibly with positional and/or
keyword arguments, and you get back a returned object. How is this
different from any other function? (Yes, by this definition a class
could be called an "object function". But the line is already somewhat
blurry; if I've read my history correctly, "int" used to be a
function, but now it's a type. A class is really just a special type
of factory function, just as a generator function is.)

ChrisA



More information about the Python-list mailing list