python-3.x - Python 3 中还有协程吗?

标签 python-3.x yield coroutine

这里有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/

相关文章:

python - 在循环结果集时插入行

haskell - 使用 Data.Machine,如何将两个 ProcessT 组合在一起来修改两个不同的状态?

python - 从 Python 中的文件中读取随机行,这些行在其他 4 行通过之前不会重复

python - 我想在给定的虚拟函数中更新我的函数 interpolate()

javascript - 在 Meteor JS 中单击特定菜单时如何呈现部分模板

Scala-yield 可以在 for 循环中多次使用吗?

android - Kotlin 协程resumeWithException 错误

task - 如何在Julia中杀死任务/协程?

python - 在 Python 中使用 'for' 的无限循环

python - 在 Python 3.3 中是否有一种漂亮的 yield 方法?