# Xlator problem

John

I am trying to use Xlator from your cbook module, to parse some expressions in python to a mathtext raw string. Something like this:

texdict = {

    '**':r'^','sqrt':r'\sqrt','[':r'_{',']':r'}',

'sin':r'\rm{sin}','cos':r'\rm{cos}',

'alpha':r'\alpha ','beta ':r'\beta ','gamma':r'\gamma '

} #Can be extended to acomodate new strings

texdict2 = {'*':r'\times '}# to take care of the multiplication sign *

xlat = Xlator(texdict)

xlat2 = Xlator(texdict2)

for i in range(self.Neq):

eq[i] = xlat2.xlat(xlat.xlat(self.eqnEdit.GetLineText(i)))


The problem is that Xlator not only takes my raw strings and return regular strings but also escapes the backslashes. Of course this ruins the tex markup…

the other way I know to tackle this parsing, using the method string.replace() also escapes backslashes.

does anybody know of a way to parse expressions without these side-effects?