【发布时间】:2016-01-17 16:39:22
【问题描述】:
引用here:
types.CoroutineType协程对象的类型,由 async def 函数创建。
引用here:
使用 async def 语法定义的函数始终是协程函数,即使它们不包含 await 或 async 关键字。
Python 控制台会话:
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:38:48) [MSC v.1900 32
bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import types
>>> def f(): pass
...
>>> async def g(): pass
...
>>> isinstance(f, types.FunctionType)
True
>>> isinstance(g, types.FunctionType)
True
>>> isinstance(g, types.CoroutineType)
False
>>>
为什么isinstance(g, types.CoroutineType) 不计算为True?
【问题讨论】:
标签: python python-3.x async-await