from .logic import ( EQUALS, GREATER, LESSER, GREATER_EQUAL, LESSER_EQUAL, NOT, AND, OR ) from .math_ops import ADD, SUB, MUL, DIV from .strings import UPPER, INVERT from .truthy import TRUTH from .lists import LIST_INDEX, LIST_PUSH, LIST_POP from .dicts import DICT_GET # Core mixin for logic + math class StultusMixin: def __eq__(self, other): return EQUALS(self, other) def __ne__(self, other): return NOT(EQUALS(self, other)) def __gt__(self, other): return GREATER(self, other) def __lt__(self, other): return LESSER(self, other) def __ge__(self, other): return GREATER_EQUAL(self, other) def __le__(self, other): return LESSER_EQUAL(self, other) def __and__(self, other): return AND(self, other) def __or__(self, other): return OR(self, other) def __bool__(self): return TRUTH(self) # Math extensions class StultusInt(StultusMixin, int): def __add__(self, other): return ADD(self, other) def __sub__(self, other): return SUB(self, other) def __mul__(self, other): return MUL(self, other) def __truediv__(self, other): return DIV(self, other) class StultusFloat(StultusMixin, float): def __add__(self, other): return ADD(self, other) def __sub__(self, other): return SUB(self, other) def __mul__(self, other): return MUL(self, other) def __truediv__(self, other): return DIV(self, other) # String extensions class StultusStr(StultusMixin, str): def upper(self): return UPPER(self) def invert(self): return INVERT(self) def __getitem__(self, index): return LIST_INDEX(list(self), index) # Bool wrapper class StultusBool(StultusMixin, bool): pass # already supports logic # List wrapper class StultusList(StultusMixin, list): def push(self, item): return LIST_PUSH(self.copy(), item) def pop(self): return LIST_POP(self.copy()) def __getitem__(self, index): return LIST_INDEX(self, index) # Dict wrapper class StultusDict(StultusMixin, dict): def __getitem__(self, key): return DICT_GET(self, key)