So, you are saying that this line works correctly:
tn.write("widget_set G 1 1 1 \" %s \"\n" % (cur))
And this line fails?
tn.write("widget_set G 2 1 2 " + line)
So, do what the first line does. Try this:
tn.write("widget_set G 2 1 2 \" %s \"\n" % (line))
If it is easier to read, the following line is equivalent. (Note how the stirng uses '
instead of "
, so the interior "
s don't have to be escaped):
tn.write('widget_set G 2 1 2 " %s "\n' %(line))
Note that this will probably still fail if either cur
or line
have a quote character "
embedded therein.