473,320 Members | 2,133 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,320 software developers and data experts.

embedding Python and changing stdin, stdout and stderr

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
Jul 18 '05 #1
1 2577
vi*************@gmail.com (Vincent Touquet) wrote in message news:<90**************************@posting.google. com>...
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.


Checkout this thread:
http://mail.python.org/pipermail/c++...er/008014.html
Jul 18 '05 #2

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

Similar topics

4
by: Jan Knop | last post by:
Hello I am writing a Windows application where I need to redirect stdin, stdout and stderr from Python. to my application Is it a simple way of do it ? Has anyone done it using Winsock ?
22
by: Alexander Schmolck | last post by:
Two smallish things that have been bugging me; I'm not sure whether they're actually broken or not, but anyway here it goes: 1. ``os.system`` (and co): Shouldn't ``os.system``'s signature really...
0
by: lickspittle | last post by:
Hi, I have Python embedded with my other code, and when my other code opens a console and redirects stdout, stdin and stderr to it, then calls PyRun_InteractiveLoop, it immediately returns with...
2
by: Xah Lee | last post by:
Python Doc Problem Example: os.system Xah Lee, 2005-09 today i'm trying to use Python to call shell commands. e.g. in Perl something like output=qx(ls) in Python i quickly located the...
0
by: todddeluca | last post by:
I am posting code for calling almost any python function from php, because it seems generally useful. Please feel free to suggest improvements or tell me this has already been done better...
2
by: Pierre Rouleau | last post by:
Hi all, I have a consistent test case where os.popen3() hangs in Windows. The system hangs when retrieving the lines from the child process stdout. I know there were several reports related to...
0
by: Thomas Schreiner | last post by:
Hi, I'm extending a windows application (C++) by embedding Python calls. It seems to be a known problem that windows applications detach immediately from the calling console, so that all output...
1
by: raocheng | last post by:
Please see the following code. Suppose I have many shell commands to be executed. And I don't want to fork a sub shell for each command(eg: status,output = commands.getstatusoutput(cmd)) because...
0
by: Gabriel Genellina | last post by:
En Thu, 25 Sep 2008 09:49:31 -0300, Almar Klein <almar.klein@gmail.com> escribió: Use subprocess.PIPE Usually the tricky part is to figure out exactly whether there is more input or not. With...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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

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.