how to bail if stdin is empty

Antoon Pardon apardon at forel.vub.ac.be
Tue Jun 1 06:58:49 EDT 2004


Op 2004-05-31, Jon Schull schreef <schull at digitalgoods.com>:
> I want to write a filter that will take input from files on the
> command line and/or from stdin.
>
> But if nothing has been piped to stdin, I don't want my program to
> hang--I want it to do something else.
>
> This is standard behavior for pipeable-programs I believe,

No it is not. Standard behaviour for filters (on unix that is)
is to use standard input if no file arguments are given.

If you start such a program without arguments and not connected
to another programs with a pipe, such a program will hang and
wait for user input from the keyboard.

-- 
Antoon Pardon



More information about the Python-list mailing list