I have a class that has the functions mul and div implemented as follows:
def __mul__(self, other): return Foo(self.a * other) def __div__(self, other): return Foo(self.a / other) The multiplication (e.g. a * b, where a is an instance of the class Foo and b is an integer) works fine, but the division (a / b) gives an error saying the operator is not supported. How do I get around this?
TypeError: unsupported operand type(s) for /: 'Foo' and 'int'
__truediv__(/) and__floordiv__(//) instead?