Reading from an External Buffer

Miki Tebeka tebeka at cs.bgu.ac.il
Sun Mar 23 08:55:20 EST 2003


Hello Bill,

> I working on a Macintosh C program that embeds some python code. I'm
> using "PyMac_SetConsoleHandler" to suppress the SIOUX console, and
> I've created my own write handler that captures Python's stdout &
> stderr and redirects them into my C code. So far no problem.
> 
> Now I'd like to do the same for stdin, reading lines from a buffer in
> my C code and passing them to sys.stdin in my Python code.
> Unfortunately, the only thing I've found that works so far is to write
> the data to temp file in C and then read it out from Python. But
> that's a not much of solution, is it?
> 
> Any advice/pointers/tips/suggestions would be greatly appreciated.
Use a StringIO object?

HTH.
Miki




More information about the Python-list mailing list