I read in a string from a GUI textbox entered by the user and process it through pandoc. The string contains latex directives for math which have backslash characters. I want to send in the string as a raw string to pandoc for processing. But something like "\theta" becomes a tab and "heta".
How can I convert a string literal that contains backslash characters to a raw string...?
Edit:
Thanks develerx, flying sheep and unutbu. But none of the solutions seem to help me. The reason is that there are other backslashed-characters which do not have any effect in python but do have a meaning in latex.
For example '\lambda'. All the methods suggested produce
\\lambda
which does not go through in latex processing -- it should remain as \lambda.
Another edit:
If i can get this work, i think i should be through. @Mark: All three methods give answers that i dont desire.
a='\nu + \lambda + \theta';
b=a.replace(r"\\",r"\\\\");
c='%r' %a;
d=a.encode('string_escape');
print a
u + \lambda + heta
print b
u + \lambda + heta
print c
'\nu + \\lambda + \theta'
print d
\nu + \\lambda + \theta