generator/coroutine terminology

Rustom Mody rustompmody at gmail.com
Thu Mar 12 12:52:27 EDT 2015


Guess I should be pleased that I am doing as good as you (and Chris) describe.
For some reason or not I am not...

On Thursday, March 12, 2015 at 9:58:07 PM UTC+5:30, Steven D'Aprano wrote:
> 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.
> 
> Hopefully it is clear from context what we actually mean. When in doubt, we
> should be explicit.

There is a very important 'context' where both have to exist together -- teaching beginners.

foo's are written to produce g's. g's come from foo-like.

Better naming would help clarify -- your 'factory' is the best Ive seen so far.
But the docs?!?! Hoo Boy My head spins trying to grok this
https://docs.python.org/3/reference/expressions.html#generator-expressions
And thats after being familiar with the origins of the idea in
scheme/simula/CLU etc.

Noobs could be forgiven for doing worse dont you think??

I guess we need
1. A clear ontology of the base concepts (which is a buzzword for nailed-down terminology)
2. Some neat pictures would sure help (me!)



More information about the Python-list mailing list