generator/coroutine terminology

Rustom Mody rustompmody at gmail.com
Thu Mar 12 09:35:26 EDT 2015


This is more a question about standard terminology/conventions than about semantics - of course assuming I understand :-)

Say I have a simple yielding function:

def foo(x):
   yield x+1
   yield x+2

And I have

g = foo(2)

If I look at type, g's type is 'generator' whereas foo is just plain-ol 'function.'

Whereas in informal usage we say foo is a generator.

So the question:
What should we call foo and what should we call g?

Same applies when foo is a 'coroutine' ie
something having yield used in an rhs and used with '.send' from outside:
What to call foo and what to call foo(x)?



More information about the Python-list mailing list