python官网对于Callable的说明:
1.Frameworks expecting callback functions of specific signatures might be type hinted using Callable[[Arg1Type, Arg2Type], ReturnType]
.
期待信号回调函数的框架可以被简写为Callable[[Arg1Type, Arg2Type], ReturnType]
.
2.Callable[[int], str]
is a function of (int) -> str.
Callable[[int], str]
是一个入参类型为int,返回值为str的函数
3.The subscription syntax must always be used with exactly two values: the argument list and the return type. The argument list must be a list of types or an ellipsis; the return type must be a single type.
这种写法必须使用两个确定的值才能使用,即参数列表和返回类型。参数列表是必须是一组类型或一个省略号...,返回类型必须是一个单值。
所以,f: Callable[[T], Iterable[U]]表示入参f是一个入参为T,返回值为Iterable[U]类型的函数即
a function to turn a T into a sequence of U(将一个T转换为一个U序列的函数)