Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python
Retrieving result from embedded execution
 

Index | Next | Previous | View Flat


mephisto_9000 at hotmail

May 8, 2012, 12:07 PM


Views: 446
Permalink
Retrieving result from embedded execution

Hello everyone,
We are trying to implement our own interactive interpreter in our applicationusing an embedded Python interpreter.
I was wondering what would be the best way to retreive as text the result of executing Python code. The text must be exactly the same as it would be in thestandalone interpreter.
We used to do this by changing the embedded interpreter's sys.stdout and sys.stderrwith a FILE created in C++. We could then execute code using the PyRun_InteractiveOnefunction and easily retrieve the result from the FILE. The problem is, our applicationshouldn't create any files if possible.
We also tried replacing sys.stdout and sys.stderr with a custom made Python objectwhich could be more easily read from C++. We then used the function PyRun_Stringto execute the code. The problem here is that using the Py_file_input start tokendoesn't write everything we need to sys.stdout. (i.e. executing 2+2 does not write 4).It also doesn't print a traceback to sys.stderr when there is an exception. Using theother two start tokens is impossible since we need to be able to execute more than one instruction at once. We also tried using the function PyRun_SimpleString but weencounter the same problems.
We are using python 2.7.
Any suggestions?
Thank you for your time.
Also, I'm new to mailling lists, what is the proper way to reply to someone? Should Ireply directly to someone's email adress or is there a way to answer trough the server.
F. Lab

Subject User Time
Retrieving result from embedded execution mephisto_9000 at hotmail May 8, 2012, 12:07 PM
    Re: Retrieving result from embedded execution wrw at mac May 8, 2012, 12:44 PM
    Re: Retrieving result from embedded execution rosuav at gmail May 10, 2012, 7:48 PM
    Re: Retrieving result from embedded execution stefan_ml at behnel May 10, 2012, 9:45 PM
        Re: Retrieving result from embedded execution jeanpierreda at gmail May 11, 2012, 10:36 AM
    Re: Retrieving result from embedded execution rosuav at gmail May 11, 2012, 11:05 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.