Until now a generator was a producer: it handed values out and nothing came back. A generator can also receive values, and be told about errors or asked to stop. These features make it a two-way channel, and they were the foundation for Python’s early coroutines. You will use them less often than plain yield, but they explain how generators really work, and they show up in tools you will meet later.
More lessons in Complete Python Programming