Redirecting I/O in embedded Python
b.scharpf at tesionmail.de
Fri Jun 25 15:27:37 CEST 2004
Heather Coppersmith <me at privacy.net> schrieb:
> On 25 Jun 2004 12:11:48 GMT,
> Bertram Scharpf <b.scharpf at tesionmail.de> wrote:
>> 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.
Yes, I did already think of that solution. But compared to
that mentioned above, it wouldn't be less effort in
programming for me, but rather a loss in efficiency I
suppose. (Additional modules would be loaded and strings
would be copied once more.)
Thank you, anyway.
More information about the Python-list