Uwe Stöhr wrote:
Bo Peng schrieb:

What is wrong with this python code:

document.body[h][j] = "|"
This is the lyx2lyx handling. "document" is a string array that contains the whole LyX-document.
"document.body[h]" returns a line. I can set this simply by
document.body[h] = "blabla"
But I cannot set single characters like this:
document.body[h][j] = 'a'
This is, as someone else said, because strings are immutable: document.body[h] is a string, and you can't change it. You need to do something like
   oldstr = document.body[h]
   newstr = oldstr[:j-1] + 'a' + oldstr[j+1:]
   document.body[h] = newstr
though I'm sure I made some syntax error there, and there's probably some simpler way to do it, too.

rh

thanks and regards
Uwe

Reply via email to