In python yield can be used to transfer information in both directions.
yield 'hello'
will generate (vs return) the string "hello", whereas
x = yield
will receive a value from .send()
method.
The output of the example blow will be:
$ python yield_example.py
0
1
2
Exiting out of here