How do I check if stdin has some data?
I've been using
if not sys.stdin.isatty()
Here's an example:
import sysdef main(): if not sys.stdin.isatty(): print "not sys.stdin.isatty" else: print "is sys.stdin.isatty"
Running
$ echo "asdf" | stdin.pynot sys.stdin.isatty
sys.stdin.isatty()
returns false if stdin
is not connected to an interactive input device (e.g. a tty).
isatty(...) isatty() -> true or false. True if the file is connected to a tty device.