PyRun_File

R

Roberto

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top