PyRun_File

Roberto rob02omni at vodafone.it
Thu Feb 5 13:11:25 EST 2004


I cant get result from PyRun_File maybe someone can get me in the right
direction??

Follow code:


                    PyObject* localDict;
                    PyObject* mainModule;
                    PyObject* mainModuleDict;


                    int i=Py_file_input;

                   Py_Initialize();

                    mainModule=PyImport_AddModule("__main__");

                    if(mainModule==NULL) { }
                    mainModuleDict=PyModule_GetDict(mainModule);
                    localDict = PyDict_New();


                   FILE *fpOut = fopen ("temp.py", "w");

                    fwrite (tempStr , 1 , hdlsize, fpOut);

                    fclose(fpOut);

           FILE *fpIn = fopen ("temp.py", "r+");

                      //int tempPyResult = PyRun_SimpleFile (fpIn,
"temp.py");
                      PyObject* tempPyResult =
PyRun_File(fpIn,"temp.py",i,mainModuleDict,localDict);
                      int lenTempPyResult = PyString_Size(tempPyResult);
                      char* stempPyResult = PyString_AsString(tempPyResult);
                  Py_Finalize();

end code

When i try to read tempPyResult i cant get result?

I know that maybe is easy but i can figure out!

Please Help!
-- 
Thanks Rob





More information about the Python-list mailing list