using pexpect to control python
Cameron Laird
claird at lairds.us
Tue Aug 24 09:08:12 EDT 2004
In article <412b14c2 at duster.adelaide.on.net>,
Adrian Casey <news at outbacklinux.com> wrote:
>Maurice LING wrote:
>
>> I know this might sounds wierd but I'm wondering if I can use pexpect or
>> os.popen3 function to invoke and control python interpreter to make it
>> act like a python interpreter in python?
>>
>> maurice
>
>Yes, should be possible. I have used tcl expect to call other expect
>scripts successfully in the past. You can use pexpect to control any
>command-line tool.
>
>What are you trying to achieve?
>
That last is *always* an apt question.
Don Libes invented Expect. Expect is a wonderful, wonderful thing;
at the same time, its purpose is to mollify "programs with crappy
interfaces" (his words), so it's dispensable and inherently sub-op-
timal, in a sense I think we can make precise. The point here is
that, whenever you're considering controlling a Python-based appli-
cation PP with Expect (or pexpect or ...), you should first invest
at least ten seconds analyzing whether you're better off re-doing
PP's interface.
More information about the Python-list
mailing list