embedding Python in Python

Chen chenpuqing at 163.net
Mon Mar 3 21:24:00 EST 2003


<Kasper.Souren at ircam.fr> wrote in message
news:mailman.1046741647.23523.python-list at python.org...
> Hi,
>
> Maybe this has been done or asked before, but with Google I couldn't find
> anything about it.
>
> I want to make an interface from TeXmacs to Python (and later IPython). I
> translated the C++ example (mycas.cc) into mycas.py and it works fine. But
> now I want to embed (..or call it what you like..) a Python interpreter in
> mycas.py.
>
> Thus I would like to be able to write something like:
>
> py_interpreter_instance = Python_Embedded_Interpreter()
> output_string = py_interpreter_instance.execute(command_string)
> or
> py_stdout, py_stderr = py_interpreter instance.execute(command_string)
>
> I took a look at IPython's code, which implements something similar. It
works
> by trapping the stdout and stderr, but I hope that there is a nicer way to
> do this...
>
> I wouldn't mind writing the Python_Embedded_Interpreter class myself. I
played
> with the idea of simply using eval() but eval("print") doesn't even work
as
> expected.
>
> bye,
> Kasper
>
>
use exec() instead.

Chen







More information about the Python-list mailing list