Python Interactive Shell - outputting to stdout?

Avi Berkovich cold_fusion at
Tue Dec 28 02:45:08 CET 2004

Avi Berkovich wrote:
> Hey,
> I can't make it work, I don't get any data from either stdout nor stderr.
> If I send lines and then close the stdin pipe, I may get an exception 
> message from several lines up.
> I tried manually reading from the stdout pipe, but it just blocks and 
> hangs no matter what I send over via the stdin pipe.
> This behavior isn't presented by the command line interpreter by any 
> chance.
> Any suggestions?


I didn't manage to get the pipes working, and finally decided to embed 
the interpreter into the program, though another option is to embed  it 
into a simple console program consisting of the interpreter 
initialization and input reading, and just pipe into that.

Code for simple interpreter embedded program:

#include <stdio.h>
#include <python.h>

int main()
	char execString[128];


	while (1)
		if (!strcmp(execString, "QUIT PROGRAM"))


This program works well with pipes, though in order to issue the command 
  I have to write "\n\r\n" (not "\r\n" or "\n" ?!) to the pipe.


More information about the Python-list mailing list