Embedding Python and command history

Stefan Bellon sbellon at sbellon.de
Wed Sep 20 06:08:53 EDT 2006


Hi all!

I'm embedding Python in my own C (or rather Ada, but via the C
interface) program. Everything runs fine. But I have a small question
regarding command history. Let's take the simplest example:

#include <Python.h>

int main(void)
{
  Py_Initialize();
  PyRun_InteractiveLoop(stdin, "<stdin>");
  Py_Finalize();
}

When I compile this an run it, then I get control characters printed
when I press cursor keys. When I start the "real" python interpreter,
then I have command history via cursor keys.

How can I make use of command history when embedded Python via
PyRun_InteractiveLoop?

Thanks a lot for your hints in advance!

-- 
Stefan Bellon



More information about the Python-list mailing list