embedded python example: PyString_FromString doesnt work?

David Harris david at palmernet.net
Wed Mar 23 18:22:15 EST 2005


I'm trying the embedded python example here:
http://www.python.org/doc/2.3.2/ext/pure-embedding.html

int
main(int argc, char *argv[])
{
    PyObject *pName, *pModule, *pDict, *pFunc;
    PyObject *pArgs, *pValue;
    int i;

    if (argc < 3) {
        fprintf(stderr,"Usage: call pythonfile funcname [args]\n");
        return 1;
    }

    
    Py_Initialize();
    pName = PyString_FromString(argv[1]);

....
}

But it seems to break at the line;
pName = PyString_FromString(argv[1]);

it always seems to return null whatever string is used as a parameter?
Can anyone explain or provide a working example?

TIA




More information about the Python-list mailing list