Pexpect is a pure Python module that makes Python a better tool for controlling and automating other programs. Pexpect is similar to the Don Libes Expect system, but Pexpect as a different interface that is easier to understand.
It runs programs and watches output. When output matches a given pattern Pexpect can respond as if a human were typing responses.