I’m trying to convert the output of WolframClient to Python. Here’s a toy example:
from wolframclient.evaluation import WolframLanguageSession from wolframclient.language import wl, wlexpr def get_session(): session = WolframLanguageSession() session.evaluate(wlexpr('Range[5]')) #warmup return session session = get_session() print(session.evaluate("Solve[a[0]==5/3,a[0]]]"))
Giving
((Rule[Global`a[0], Rational[5, 3]],),)
I’m hoping to instead get something simpler (a string is sufficient):
"a[0] = 5/3"
Motivation:
Ideally I’d like to port the output of mathematica to Sympy. I’ve tried Sympy’s Mathematica parser, but it doesn’t recognize any of the "non-whitelisted" expressions such as Rational[5,3]
. I’ve tried using Mathematica’s InputForm
function but that doesn’t seem to work.