embedded python example: PyString_FromString doesnt work?
Brano Zarnovican
zarnovican at pobox.sk
Thu Mar 24 09:39:47 EST 2005
Hi David !
I cannot see anything wrong on your code. So, I'm posting my working
example.
Hint: try to determine, why it is returning NULL (the PyErr_Print()
call)
BranoZ
#include <Python.h>
int
main(int argc, char *argv[]) {
PyObject *s;
int ret;
if (argc < 2)
return -1;
Py_Initialize();
s = PyString_FromString(argv[1]);
if (s == NULL) {
PyErr_Print();
return -1;
}
ret = PyObject_Print(s, stdout, 0);
Py_XDECREF(s);
if (ret < 0) {
PyErr_Print();
return -1;
}
return 0;
}
$ cc test_String.c -o test_String -I /usr/include/python2.3 -lpython2.3
$ ./test_String
$ ./test_String hello
'hello'
More information about the Python-list
mailing list