synthtize comparison for MOnumber

This commit is contained in:
Bertrand Benjamin 2018-03-15 16:38:25 +03:00
parent 64ee8981ee
commit b0ff919693
1 changed files with 2 additions and 21 deletions

View File

@ -10,6 +10,7 @@ from decimal import Decimal
from .exceptions import MOError
from ..coroutine import coroutine, STOOOP
from ..renders import tree2txt, tree2tex
from functools import total_ordering
__all__ = ["moify", "MO", "MOstr"]
@ -116,6 +117,7 @@ class MO(object):
return str(self.value)
@total_ordering
class MOnumber(MO):
""" Base number math object (int or Decimal) """
@ -266,27 +268,6 @@ class MOnumber(MO):
except AttributeError:
return self.value < other
def __le__(self, other):
""" <= a MOnumber """
try:
return self.value <= other.value
except AttributeError:
return self.value <= other
def __gt__(self, other):
""" > a MOnumber """
try:
return self.value > other.value
except AttributeError:
return self.value > other
def __ge__(self, other):
""" >= a MOnumber """
try:
return self.value >= other.value
except AttributeError:
return self.value >= other
def __hash__(self):
return self.value.__hash__()