example-code-2e/attic/control/coro_simple_demo.rst
2015-04-15 04:48:25 -03:00

14 lines
282 B
ReStructuredText

>>> def coroutine():
... print('coroutine started')
... x = yield
... print('coroutine received: {!r}'.format(x))
...
>>> coro = coroutine()
>>> next(coro)
coroutine started
>>> coro.send(42)
coroutine received: 42
Traceback (most recent call last):
...
StopIteration