Converting C strings to Python problem

Phil Rittenhouse phil.rittenhouse at dspfactory.com
Tue Feb 26 12:28:02 EST 2002


Hi,

I'm trying to pass a path string (eg. "c:\spam\test.exe") from C to python,
but python is interpreting the string as "c:\spam<tab>est.exe".

I've run into this problem with converting C strings to Python strings using
Py_BuildValue().   When converting a C string with backslashes to a
python string, the string (including backslashes) is copied exactly.  Sounds
reasonable, except that, according to the doc's, Python
uses two character escape sequences to represent things like tabs (\t).

Should the conversion process convert backslashes in C to double backslashes
in Python?   What is the recommended method for doing the C string to python
string conversion?  Does PyString_FromString() behave differently?

Thanks for your help,
Phil
------------
Phil Rittenhouse
phil.rittenhouse at dspfactory.com
Software Developer
Dspfactory Inc.










More information about the Python-list mailing list