【问题标题】:Backward compaitablity of type hinted python 3 code [duplicate]类型提示的python 3代码的向后兼容性[重复]
【发布时间】:2015-08-10 21:25:12
【问题描述】:

有没有办法让包含type hinting annotations 的python 3 代码也可以与python 2 一起使用?

def get(axyz: list, window_size: int=WINDOW_SIZE) -> numpy.array:
    return numpy.array(axyz)

更重要的是,这可能吗?

【问题讨论】:

    标签: python python-2.7 python-3.x type-hinting


    【解决方案1】:

    类型注解语法在 python2 中无效。 pep484 提到了与 python2 兼容的存根文件。

    【讨论】:

      猜你喜欢
      • 2018-10-18
      • 1970-01-01
      • 1970-01-01
      • 2016-05-25
      • 1970-01-01
      • 1970-01-01
      • 2020-01-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多