473,324 Members | 2,511 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

PyRun_File

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,localDi ct);
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
Jul 18 '05 #1
0 1731

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Søren Johansen | last post by:
Hi, having had a number of problems with PyRun_File in my application embedding Python, I decided to load scripts into memory myself and execute them with PyRun_(Simple)String. This works fine...
4
by: Preston H | last post by:
Hello, someone may have tackled this problem before but I have searched the google newsgroups up and down and I can't find anything on this. I am trying to write an embedded python program in C++...
9
by: Kim | last post by:
Hi everyone, I'm writing a embeded python program, and I want to evaluate some expression by calling function: PyRun_SimpleString("print 'hello'") I don't want to output it to stdout but...
0
by: Gi?rgenes | last post by:
Hi, When I use, for example, PyRun_File to run a script and an error occur, the error is sent to stderr. What can I do to avoid it? To cleanly capture the error w/out it beeing sent to stderr....
0
by: Shane | last post by:
Greetings, I've been trying to get PyRun_SimpleFile to work from Delphi without success, has any one done this? Doing it in C/C++ is trivial, but I need Delphi and I'm not a Delphi expert. ...
4
by: Wesley Henwood | last post by:
What is the proper way to pass command line parameters to a python script called from C++? I'm tryng this: path = "c:\\someDir\\someScript.py param1 param2 param3";...
3
by: marcus.obrien | last post by:
Hi, on startup my embedded python comes up with "import site failed use -v". Later python crashes on Pyrun_file(). This is the first time I have used python and I would like to know does it...
1
by: john.pye | last post by:
Hi all, I have an application that is using embedded python to offer some scripting ability. An API is exposed via SWIG, and I am accessing that API from my embedded python interpreter. ...
1
by: moshehaim1 | last post by:
Hi, I am working with C++ code that needs to be maintained both in debug and release versions. The environment is Windows 32 bit with MSVC8. I downloaded the python installation for Win32 and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.