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. Pexpect allows your script to spawn a child application and control it as if a human were typing commands.
Project page: https://pexpect.readthedocs.org/en/stable/
kcp -i python3-ptyprocess
kcp -i python3-pexpect