>>>>> "Flavio" == Flavio Codeco Coelho <fcc...@fi...> writes:
Flavio> the other way I know to tackle this parsing, using the
Flavio> method string.replace() also escapes backslashes.
Flavio> does anybody know of a way to parse expressions without
Flavio> these side-effects?
I think you are making a conceptual error here (one that I made too
earlier when I was working on mathtext). There is no such thing as a
raw string. the r'\somestring' is a hint to the python parser telling
it to escape all the slashes so you don't have to. Ie, raw strings
and strings are the same thing, and the r prefix just makes it easier
to write strings that have slashes in them.
>>> r'\hi mom'
'\\hi mom'
So when these strings come back to you from Xlator or string.replace
displaying the \\, that is the right thing to do.
See, for example,
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=7xznb699ph.fsf%40ruckus.brouhaha.com&rnum=14&prev=/groups%3Fq%3Draw%2Bstring%2Bgroup:*python*%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26scoring%3Dd%26start%3D10%26sa%3DN
JDH
|