我正在试验Python中的类型注释.大多数情况都很清楚,除了那些以另一个函数为参数的函数.
考虑下面的例子:
from __future__ import annotations
def func_a(p:int) -> int:
return p*5
def func_b(func) -> int: # How annotate this?
return func(3)
if __name__ == "__main__":
print(func_b(func_a))
输出仅打印15
.
我应该如何注释func_b( )
中的func
参数?