Py学习  »  Python

在类方法_init__;中的python类型中,我对1属性的参数类型注释是:Callable=None,注释状态是什么?

Alex • 3 年前 • 1590 次点击  

这个 初始化 类中的函数按以下方式进行注释:

    def __init__(self, directory: str, transforms: Callable = None, extension: str = '.jpg'):

问题是什么 Callable = None 指的是。

按照惯例,如果 transforms -参数注释意味着引入一个可调用(即函数),然后需要定义输入参数和输出,例如: transforms: Callable[[int,int], int] 在哪里 [int,int] would be the function parameters as input, and the latter int将是回报。但事实并非如此。

这是什么意思 Callable 在这种情况下,注释是否作为输入和返回?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/130876
 
1590 次点击  
文章 [ 2 ]  |  最新文章 3 年前