embedding, PyString_FromString

Lance lbrannma at cablespeed.com
Sun Dec 15 15:59:16 EST 2002


Hi All,

This fails and I don't know why. The error message is:

Traceback (most recent call last):
  File "<string>", line 1, in ?
NameError: name 'pstr1' is not defined

The code is

int main(int argc, char* argv[])
 {
  Py_Initialize();
  PyObject *pstr1;
  char pstr[20];
  strcpy(pstr,"recode");
  pstr1 = PyString_FromString(pstr);
  PyRun_SimpleString("print 'hello '+pstr1");
  return 0;
 }

Any suggestions will be much appreciated.

Thanks,
Lance





More information about the Python-list mailing list