【发布时间】:2017-01-20 08:33:12
【问题描述】:
在typing模块中使用List、Tuple等有什么区别:
from typing import Tuple
def f(points: Tuple):
return map(do_stuff, points)
相对于直接引用 Python 的类型:
def f(points: tuple):
return map(do_stuff, points)
我什么时候应该使用一个而不是另一个?
【问题讨论】:
-
第一个在 SO 的语法高亮上看起来好多了!
-
读一读,我发现自己问了同样的问题,直到我读到这篇文章。 docs.python.org/3/library/typing.html
标签: python type-hinting python-typing