Getting output from embedded python program

Brad Clements bkc at Murkworks.com
Mon Apr 19 10:54:32 EDT 2004


_
"Kim" <thefirstofnovember at yahoo.com> wrote in message
news:2aa196bb.0404190554.74631058 at posting.google.com...
> Hi everyone,
> I'm writing a embeded python program, and I want to evaluate some
> expression by calling function:
>
> PyRun_SimpleString("print 'hello'")
>
> I don't want to output it to stdout but putting it into string somehow
> sothat I can process it.
>
> Do anybody know how I can do that?
> Thanks very much
> Kim


Sure.

You can create a StringIO object and assign it sys.stdout

Or, you can create C "object" with a write method and assign an instance of
that object to sys.stdout.

-- 
Novell DeveloperNet Sysop #5







More information about the Python-list mailing list