generator/coroutine terminology

Marko Rauhamaa marko at pacujo.net
Mon Mar 16 08:32:34 EDT 2015


Steven D'Aprano <steve+comp.lang.python at pearwood.info>:

> If I .send() into either of the generators above, its a conceptual
> mistake and I should get an error. The fact that I don't is an
> implementation detail, and one which hopefully will be fixed.

So what we have now is:

  (1) plain iterators

  (2) generator iterators

  (3) coroutine generator iterators

At the moment (2) and (3) are unified, which you don't like. (1) and (2)
are not unified, which I don't like.

You and I can pretend (2) didn't have send(), throw() and close() and be
satisfied. Then, generator iterators are just plain iterators from the
point of view of the application programmer.

However, it seems to me close() is intended to be used for (2) as well.
The way I'm reading PEP 342, it seems to encompass the objectives of the
rejected PEP 325  ("Resource-Release Support for Generators"):


Marko



More information about the Python-list mailing list