On Tue, January 13, 2009 17:45, John Fouhy wrote: > 2009/1/14 Damon Timm <damont...@gmail.com>: >> This works when I do have something coming via stdin ... but if I run >> the script without piping something first ... it just sits there (I >> assume, waiting for some stdin) ...
This is playing a dangerous game, though, of introducing a race condition. Is there nothing on the standard input RIGHT NOW because the source on the other end of the pipe hasn't managed to generate anything yet, or because there's nothing piped? A better approach is either to explicitly specify whether to read from stdin or a file, as Alan demonstrated (and the fileinput module implements this for you, by the way), or to see if stdin is connected to a terminal or not. So instead of seeing if anything's showing up (and introducing timing dependencies and uncertainty), see if it's attached to a real terminal at all. On Unix, os.isatty(sys.stdin) will tell you this. steve _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor