Problems with select() and stdin

jepler at jepler at
Sun Aug 18 17:34:20 CEST 2002

When you take input from a pipe, sys.stdin corresponds to the program on
the left of the pipeline, not the terminal where the program is running (if

If you open the special device /dev/tty and assign the result to sys.stdin,
raw_input reads from the terminal again, as in this example:

$ echo "standard input" | python -c '
import sys;
sys.stdin = open("/dev/tty");
print raw_input("? ")'
standard input
? _

This advice only applies to unix where /dev/tty is supported.


More information about the Python-list mailing list