I am new to sympy, and I am following a guide to using it for physics.
There’s a line which says:
smp.symbols(r'\theta_1 \theta_2', cls=smp.Function)
What does the r before the '\theta_1 \theta_2' means? I have not been able to find anything…
So far, I have noticed that removing it
Screenshot without the r, using jupyter
kind of messes with the variable name, given that it has a \ for "LaTeX".
Thanks for any insights you may provide!!
>Solution :
r"xxx" indicates a "raw string", in which backslash escapes are not processed. The string "\theta" by itself contains 5 characters: a tab, and the letters "heta". But the string r"\theta" contains 6 characters: a backslash, a ‘t’, and then ‘heta’.
You can also write "\\theta_1 \\theta_2", but raw strings save you from having to double the backslashes.