annoying stdin/stdout + pipes problem
gdamjan at gmail.com
Sun Sep 23 18:24:04 CEST 2007
> I want to create a program that reads input from stdio that can prompt
> a user for input while doing so without getting into problems.
> As you can see I have commented out what I'd like to do but do not
> know how to. Can I somehow halt the previous print to stdout (cat
> input.txt) - if so can I then start it again, and how?
The trick (which works on Linux for sure) is to open /dev/tty and ask
question/get input on/from it.
fp = open('/dev/tty', 'r+')
answer = fp.readline().strip()
I'm not usre for other *nix-es, and on Windows this will surelly not work
More information about the Python-list