Hello,
   I'm new to Python.I want to embed Python interpreter into my C++ application powered by Borland C++ Builder 2006.
   I have written some C++ code in order to evaluate Python script file, but PyImport_Import() calls failed.I really don't know what's wrong with my cpp code.It always return a NULL value.
   Any advice is appreciated!


int TPython::ExecuteScript(const char * pszFileName)
{      

        PyObject *pFileName, *pModule, *pDict, *pFunc;
        PyObject *pArgs, *pValue;
       
        pFileName = PyString_FromString(pszFileName);
        /* Error checking of pFileName left out */
        if(!pFileName)
        {
                trace1(("pFileName == NULL "));
        }

        pModule = PyImport_Import(pFileName);     // always failed, returned NULL:(
        Py_DECREF(pFileName);

        if (pModule != NULL)
        {          
           ................
        }
        else
        {
            PyErr_Print();
            trace1(("Failed to load \"%s\"\n", pszFileName));
            return 1;
        }
       
        return 0;
}


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to