def __div__(self, other): if other.__class__ == self.__class__: return self * inverse(other.value, self._base) elif type(other) in [int, long]: return self * inverse(other, self._base) else: raise TypeError
def __rdiv__(self, other): return self.__class__(other * inverse(self.value, self._base), self._base)