Python & Expect

Peter Hansen peter at
Wed Dec 10 14:57:18 CET 2003

Jeff Wagner wrote:
> Is there an Expect-like module for Python that is cross platform and, for the most part, does what
> Expect does? A number of years ago, I wrote some Tcl scripts using Expect for automation. I am
> trying to convince my good friend who I worked with at the time to try Python. He said, "what about
> Expect?"
> I have heard of a Pexpect but was told that it didn't run on win32 and he needs win32 and Linux
> support both.

Hmmm... let's see what Google brings up...  (typing)

Wow!  Look at that!  Pexpect is the first hit.  Let's try accessing that
page and see what it says.  (click)  Ah, there's a "Requirements" link: (click)

Pexpect was written and tested with Python 2.1. It should work on earlier versions 
that have the pty module. ...

pty module
Any POSIX system (UNIX) with a working pty module should be able to run Pexpect. 
The pty module is part of the Standard Python Library, so if you are running on 
a POSIX system you should have it. The pty module does not run as well on all platforms. 
I have taken effort to try to smooth the wrinkles out the different platforms. To 
learn more about the wrinkles see Bugs and Testing.

Pexpect does not currently work on the standard Windows Python(see the pty requirement); 
however, it seems to work fine using Cygwin. ...


Okay, Jeff, consider your wrist slapped for not even trying...  :-)


More information about the Python-list mailing list