【发布时间】:2018-02-04 10:30:55
【问题描述】:
只是callable吗?与此同时,我一直使用function 作为我的IDE,将callable 视为bool。
def func(a: int, b: str, callback: ???)
【问题讨论】:
标签: python python-3.x type-hinting
只是callable吗?与此同时,我一直使用function 作为我的IDE,将callable 视为bool。
def func(a: int, b: str, callback: ???)
【问题讨论】:
标签: python python-3.x type-hinting
是的,typing.Callable 是回调的正确提示。
另请参阅 PEP 484 的 Callable section:
期望特定签名的回调函数的框架可以使用
Callable[[Arg1Type, Arg2Type], ReturnType]进行类型提示。
【讨论】: