Use exec to replace the shell process with the python one. The python script will have to replace itself with a new shell process when the right password is input.
kbint.py
#!/usr/bin/env python
import os
def inf(secret):
    try:
        attempt = 0
        while secret != attempt:
            attempt = raw_input(">")
        os.execv("/bin/sh", ["sh"])
    except:
        inf(secret)
inf("abc")
$ exec ./kbint.py
Not sure about the windows equivalent...