def __eq__ (self, rhs):
if (not isinstance(rhs, ConstantExpr)):
return False
if (self.type() == rhs.type()):
return (self.value() == rhs.value())
elif (self.type() == int and rhs.type() == Fraction):
return (Fraction(self.value(), 1) == rhs.value())
elif (self.type() == Fraction and rhs.type() == int):
return (self.value() == Fraction(rhs.value(), 1))
else:
sys.exit("ERROR: invlaid __eq__ scenario of ConstExpr")
评论列表
文章目录