Embedded python console and FILE* in python 3.2

F L mephisto_9000 at hotmail.com
Mon Aug 8 13:14:57 EDT 2011

> Is the `code` module (http://docs.python.org/library/code.html) an insufficiently exact copy of an interpreter for you?
The problem isn't really to emulate the behavior of the interpreter as to obtain the result of the execution as a string in c++. The code module doesn't seem to help with this matter.
> I assume you could simply use PyFile_FromFd?
According to the documentation using PyFile_FromFd seems unadvised, but I'll give it a try.
> The more elegant solution might be to create custom Python file-like> objects for std{in,out,err} that communicate directly with your application.I thought about this, but I need the console window to be non-modal and I'm afraid that replacing stdin witha custom file-like object would cause a blocking call. Executing python in a second thread would solve this problembut our application isn't multi-threaded and executing python in another thread causes errors.
Maybe I could use a file-like object to communicate the results to my c++ application and use the code module to execute code only when the c++ application needs it.
Thanks a lot for the tips, have a nice day.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110808/ef4616a9/attachment.html>

More information about the Python-list mailing list