generator/coroutine terminology

breamoreboy at gmail.com breamoreboy at gmail.com
Thu Mar 12 09:57:27 EDT 2015


On Thursday, March 12, 2015 at 1:35:48 PM UTC, Rustom Mody wrote:
> 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)?

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

If this comes out badly please free to shout as I'm on gg :)



More information about the Python-list mailing list