Next / Previous / Contents / Shipman's homepage

3.8. Rational.__div__(): Implement division

Here's the formula for dividing one fraction by another:

rational.py
    def __div__ ( self, other ):
        """Implement division.
        """
        return  Rational ( self.n * other.d, self.d * other.n )