这里有Python 2中协程的详细解释http://www.dabeaz.com/coroutines/ 。然而,搜索Python 3 official documentation对于关键字“coroutine”和“(yield)”,我只找到特定于 asyncio 模块的 asyncio.coroutines,并且它们使用“yield from”语法。
最佳答案
是的。 Beazley 编写的所有内容都继续适用于 Python 3。
注意。在 2.7 yield statements 文档中,“coroutine”仅出现在“另请参阅 PEP 0342”标题中。对于 3.x,“另请参阅”部分以及该链接已移至 previous chapter 中的yield expression 部分。 。 3.x yield statement文档有(yield <expr>)
而不仅仅是(yield)
.
关于python-3.x - Python 3 中还有协程吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28737092/