|
|
|
|
|
by gjm11
5586 days ago
|
|
In case anyone's wondering about the two PEPs GvR mentions: PEP 380 (http://www.python.org/dev/peps/pep-0380/) would provide a convenient way for one generator function to yield all the values of another as part of its work. At the moment you have to say something like for x in foo:
yield x
which isn't all that bad in itself but breaks down when your caller starts sending values back to you, coroutine-style. (Because they go to foo and you never get to see them.)PEP 3152 (http://www.python.org/dev/peps/pep-3152/) uses the generator mechanism (as enhanced by PEP 380) which already provides something rather like coroutines, and adds some syntactic sugar to let you write coroutines that look like coroutines. |
|