[Tutor] how to check for stdin?
Tue, 6 Feb 2001 11:00:55 +0100
On 2001.02.05 16:45:30 +0100 Michael P. Reilly wrote:
> I doubt that you could check on windoze, but in a UNIX environment
> there is knowledge of whether a open file is attached to a terminal or
> not. A method called "isatty()" returns true if associated with a
thank you for that hint. Happy enough my script need not run
under windows... And it works. cool.
however, there was a typo on the second line, your prg should read:
$ cat eggs.py
if not sys.stdin.isatty(): # redirected from file or pipe
stdin_data = sys.stdin.read()
stdin_data = 'not read from stdin'