472,977 Members | 2,080 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,977 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 1686

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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.