how to get the output of embedded python?
Jean-Luc Fontaine
jfontain at winealley.com
Wed Feb 14 05:06:53 EST 2001
David Bolen wrote:
> Jean-Luc Fontaine <jfontain at winealley.com> writes:
>
> > With python, according to my research on the subject (which may be wrong
> > since I am new in python), there does not seem to be any simple way to
> > gather the output of a script passed for example to PyRun_SimpleString.
> > I also looked at the huge piece of code that handles the interactive
> > part of python so that typing 1+1 at the prompt prints 2.
>
> You may need to be a little more clear on what you mean by "output" -
> is it anything the script generates,
Yes. That is whatever output you would see when in interactive mode, if
that makes any sense...
> or are you looking for
> information that is otherwise sent to sys.stdout? The former may be
> impossible, given that scripts may write files or do various
> operations.
That does not seem to matter in other scripting languages, such as Tcl or
Perl: calling an internal eval C function with a script as argument returns
the result of the script (not what comes out on stdout or stderr), which
may be empty.
For example, if I define a function foo that returns a string, invoking
eval("foo()") in C would return that string. Is not that the behavior of
python in interactive mode, for example?
--
Jean-Luc Fontaine mailto:jfontain at winealley.com http://www.winealley.com
More information about the Python-list
mailing list