そのため、数学に関する Web アプリケーションを作成する予定であり、ユーザー入力を変更せずに SymPy 式に変換する必要があります (簡略化)。この例のように、この動作をキャンセルしたいと思います。
>>> srepr(Rational(2,4)) #this is the problem
'Rational(1, 2)'
>>> srepr(Rational(2,4,evaluate=False)) #doesn't work
Traceback...
しかし、私は他のタイプの表現でそれを行うことができました。
>>> srepr(Pow(x,(Mul(e,e,evaluate=False)),evaluate=False)) #nice
"Pow(Symbol('x'), Mul(Symbol('e'), Symbol('e')))"
>>> srepr(sqrt(Integer(8))) #not what I want
'Mul(Integer(2), Pow(Integer(2), Rational(1, 2)))'
>>> srepr(Pow(Integer(8),Rational(1,2),evaluate=False)) #this is the way
'Pow(Integer(8), Rational(1, 2))'
>>> from sympy import E
>>> log(E,evaluate=False)
log(E)
また、すべての表現が評価されるべきではないことを SymPy に伝える方法はありませんか?