Redirecting I/O in embedded Python

Heather Coppersmith me at privacy.net
Fri Jun 25 08:37:38 EDT 2004


On 25 Jun 2004 12:11:48 GMT,
Bertram Scharpf <b.scharpf at tesionmail.de> wrote:

> Hi,
> in one of my C programs, I call embedded Python code. Now, I
> would like to redirect stdin/stdout to strings I can assign
> to/read out within the C code.

> This should be a solvable problem creating modules that have
> a member function 'write' or 'readline' respectively and
> assigning them to sys.stdin and sys.stdout.

> Before I do this work, I would like to ask if there is a
> reported standard way to do it or if there is even the
> finished code to be obtained anywhere on the web.

Put the library reference under your pillow tonight, and read the
sections on stringio and cstringio in the morning.

Regards,
Heather

-- 
Heather Coppersmith
That's not right; that's not even wrong. -- Wolfgang Pauli



More information about the Python-list mailing list