Embedded 'C' problem?

Samuel Schulenburg samschul at pacbell.net
Sat Jun 2 03:09:22 EDT 2001


Given the following string:
EB70:|30 E8 8A 17  00 00 66 89  04 9F 83 C4  08 43 3B 5C   
0.....f......C;\

and using the following 'C' wsprintf() function to build ucPyString
causes a print format error.

wsprintf(ucPyString,"print \"\"\"%s\"\"\"",ucMsgStr);
PyRun_SimpleString(ucPyString);

ERROR:

  File "<string>", line 1
print """EB70:|30 E8 8A 17  00 00 66 89  04 9F 83 C4  08 43 3B 5C
0.....f......C;\"""
                                                                      
                   ^
SyntaxError: invalid token

The problem is final "\" in the origional string is interfering with
the final tripple quote forming a \""" which is interprited as an
escape sequence.

My question is. How can I generate a format specifier so I can have a
ucMsgStr that contains any printable characters, and does not interfer
with the Python print function?

Sam Schulenburg



More information about the Python-list mailing list