Jac*_*oge 10 python transcrypt python-3.7 python-dataclasses
对于Transcrypt Python到JavaScript编译器的 3.7.1版本,我目前正在使用新的@dataclass装饰器.根据PEP的摘要,我原本预计==, !=, <, >, >=, <=会得到支持,但似乎并非如此:
from dataclasses import dataclass
@dataclass
class C:
x: int = 10
Run Code Online (Sandbox Code Playgroud)
有些比较不起作用:
>>> c1 = C(1)
>>> c2 = C(2)
>>> c1 == c2 # ok
False
>>> c1 < c2 # crash
TypeError: '<' not supported between instances of 'C' and 'C'
Run Code Online (Sandbox Code Playgroud)
为什么不支持比较运算符,除了==和!=?或者我忽略了什么?