Pexpect is a pure Python module for spawning child applications, controlling them, and responding to expected patterns in their output. Pexpect works like Don Libes' Expect. Pexpct allows your script to spawn a child application and control it as if a human were typing commands. - Pexpect Read the Docs, https://pexpect.readthedocs.io/en/stable/index.html
Like the original Expect module by Don Libe, Pexpect launches or spawns another process and watches over it in order to control the interaction. Unlike the original Expect, it is entirely written in Python that does not quire TCL or C extensions to be compiled. This allows us to use the familiar Python syntax and its rich standard library in our code.