def parse_ratio(m): n = rt.wrap(int(str(m.group(1)))) d = rt.wrap(int(str(m.group(2)))) return rt._div(n, d)
def _div(a, b): assert isinstance(a, Ratio) and isinstance(b, Ratio) return rt._div(rt.wrap(b.denominator() * a.numerator()), rt.wrap(b.numerator() * a.denominator()))