【发布时间】:2018-01-24 08:07:26
【问题描述】:
我有一个如下所示的类
class ExperimentResult(BaseDataObject):
def __init__(self, result_type: str, data: dict, references: list):
super().__init__()
self.type = result_type
self.references = references
self.data = data
def __repr__(self):
return str(self.__dict__)
代码是用 python 3 编写的,而我试图在 python 2 中运行它。 当我运行它时,我得到了
def __init__(self, result_type: str, data: dict, references: list):
^
SyntaxError: invalid syntax
有没有“import_from_future”来解决这个问题?
【问题讨论】:
-
真正的解决方案是在 Python 2 中完全停止运行任何代码
标签: python python-2.7 python-3.x annotations type-hinting