SymPy provides a package, sympy.parsing.mathematica
, for parsing Mathematica code. The old parsing function, mathematica
, seems to be able to handle eg Greek characters fine:
from sympy.parsing.mathematica import mathematica
mathematica('λ')
Out[]:
λ
As of SymPy v. 1.11, the mathematica
function is deprecated, and is replaced by parse_mathematica
. This function, however, seems unable to handle the simple example above:
from sympy.parsing.mathematica import parse_mathematica
parse_mathematica('λ')
Traceback (most recent call last):
...
File "<string>", line unknown
SyntaxError: unable to create a single AST for the expression
Any ideas why it doesn't work and what the error message "SyntaxError: unable to create a single AST for the expression" means? Googling on this error message (in quotes) appears to give no hits.
You can use the function symbols()
instead, perhaps?
from sympy import *
symbols('lambda')
𝜆
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.