Ejemplo n.º 1
0
 def power_comp_num(self, other):
     if self.val <= 0 or not isclose(self.val, int(self.val)):
         raise OperationIsNotSupported(Number, "^", type(other))
     res = other
     for i in range(int(self.val - 1)):
         res = res * res
     return res
Ejemplo n.º 2
0
 def __pow__(self, other):
     try:
         other_op_method = getattr(other, self._operations["**"])
         return other_op_method(self)
     except AttributeError:
         raise OperationIsNotSupported(self.__class__, "**", type(other))