synthtize comparison for MOnumber

This commit is contained in:
Bertrand Benjamin 2018-03-15 16:38:25 +03:00
parent 64ee8981ee
commit b0ff919693

View File

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