Welcome to Cadabra Q&A, where you can ask questions and receive answers from other members of the community.
+1 vote

Dear all, I need to convert a Cadabra tensor expression in a python string. I am using the str(expression) command but it transforms greek indices in blank spaces. How can I solve the problem (I need both greek and latin indices)? Thanks, Mattia

in General questions by (410 points)

1 Answer

+2 votes

Do you really need the Python form, or is the Cadabra input form perhaps better? The Python form gives greek indices in the form of Unicode characters, which the Cadabra notebook does not print because the LaTeX backend does not handle them correctly. But you can do


which will produce


You can feed that back into Cadabra, e.g.

ex2=Ex("2 * "+ex.input_form());

which prints $2\alpha$.

by (64.9k points)

Thanks Kasper, I confused Cadabra form with Python form. Now input_form() works fine! Thanks, Mattia