diff --git a/mapytex/calculus/core/MO/mo.py b/mapytex/calculus/core/MO/mo.py index 7f01193..2770859 100644 --- a/mapytex/calculus/core/MO/mo.py +++ b/mapytex/calculus/core/MO/mo.py @@ -116,6 +116,15 @@ class MO(object): except AttributeError: return str(self.value) + def __hash__(self): + return self.value.__hash__() + + def __eq__(self, other): + """ == a MOnumber """ + try: + return self.value == other.value + except AttributeError: + return self.value == other @total_ordering class MOnumber(MO): @@ -254,13 +263,6 @@ class MOnumber(MO): except AttributeError: return other % self.value - def __eq__(self, other): - """ == a MOnumber """ - try: - return self.value == other.value - except AttributeError: - return self.value == other - def __lt__(self, other): """ < a MOnumber """ try: @@ -268,8 +270,6 @@ class MOnumber(MO): except AttributeError: return self.value < other - def __hash__(self): - return self.value.__hash__() class MOstr(MO): @@ -311,8 +311,13 @@ class MOstr(MO): if not val.isalpha(): raise MOError(f"An MOstr should be initiate with a alpha string, got {val}") - MO.__init__(self, value) + MO.__init__(self, val) self.is_scalar = False + self._variable = val + + @property + def variable(self): + return self._variable # ----------------------------- # Reglages pour 'vim'