python - Print x/2 as 1/2 x in Sympy -
how can tell sympy print x/2 1/2 x example? i.e. print fraction 1 on denominator times numerator?
to have write own printer, believe. hackishly might try:
mul = x/2 a, b = mul.as_two_terms() if a.is_rational , not a.is_integer: print (mul(symbol(str(a.p))/a.q, b, evaluate=false)) else: print (mul)
Comments
Post a Comment