[Tutor] Connecting to interactive program

Alan Gauld alan.gauld at freenet.co.uk
Wed Dec 8 00:41:16 CET 2004

CC'd back to tutor list.

----- Original Message ----- 
From: "Vincent Nijs" <v-nijs at kellogg.northwestern.edu>
To: "Alan Gauld" <alan.gauld at freenet.co.uk>
Sent: Tuesday, December 07, 2004 10:56 PM
Subject: Re: [Tutor] Connecting to interactive program

> Alan,
> Sorry if I was unclear.
> I would like to have python program that will (1) start an
> session of python, r, matlab or some other program and (2) allow the
user to
> pass commands to that interactive session from a shell command line
> echo 'x=3'). If the python program opens the interactive session
that will
> also allow direct input into the interactive program by the user.

That sounds pretty much what pyexpect will allow you to do.
Certainly plain ol' expect does that kind of thing. Basically
anything that reads stdin and displays on stdout or stderr
can be driven by expect and therefore by pyexpect.

> If I can get the interactive program to accept commands from a shell
> line I can figure out how to send commands from my favorite editor

Now that might be interesting :-)
I assume you have the version of vim that uses python as its
scripting language?

Alan G.

More information about the Tutor mailing list