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

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -