synthtize comparison for MOnumber
This commit is contained in:
parent
64ee8981ee
commit
b0ff919693
@ -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__()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user