embedding Python and changing stdin, stdout and stderr

  • Thread starter Vincent Touquet
  • Start date
V

Vincent Touquet

Hi,

In a project where I have embedded Python in a C++ application, I have
the need to replace what Python considers to be stdin, stdout and/or
stderr.

In sysmodule.c in the Python sources, I find the following lines of
code:

sysin = PyFile_FromFile(stdin, "<stdin>", "r", NULL);
....
PyDict_SetItemString(sysdict, "stdin", sysin);

Where stdin is the C constant FILE pointer and sysin is a PyObject
pointer.

Would it be feasible for me to provide my own PyFile to replace sysin
in sysdict ? It would seem to me that it would be sufficient to
provide the Python interpreter with a different standard in/out/err
than the one provide by the OS (through C).

best regards,

Vincent
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top