A variable annotated with C may accept a value of type C. In
contrast, a variable annotated with Type[C] may accept values that
are classes themselves - specifically, it will accept the class
object of C.
文档包括一个带有int类的示例:
a = 3 # Has type 'int'
b = int # Has type 'Type[int]'
c = type(a) # Also has type 'Type[int]'
如果
arg
接受CustomClass
的实例,则前者是正确的:如果您希望类
CustomClass
本身(或子类型),则应编写:就像写在关于Typing的文档中一样:
文档包括一个带有
int
类的示例:相关问题 更多 >
编程相关推荐