using pexpect to control python

M

Maurice LING

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
 
A

Adrian Casey

Maurice said:
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?
 
C

Cameron Laird

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.
 
M

Maurice LING

I suppose I'm actually still toying with the possibilities of what
pexpect can do with python and the question comes up.

Another thing which I'm thinking previously is how can I embed a python
interpreter (not compiler) that does line by line interpretation and
execution, in a python program? I realized that python's language
services has a compile package that can be invoked to compile python
source into python bytecodes but that's provided that the codes are in a
file. Perhaps what I'm interested may be how to embed and use the
interactive mode of python interpreter in a python program?

Thanks
Maurice
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,204
Messages
2,571,063
Members
47,670
Latest member
micheljon

Latest Threads

Top