Testing for the presence of input from stdin.

Will McDonald wmcdonald at gmail.com
Tue Jan 24 04:34:22 EST 2006

On 24/01/06, Roland Heiber <newstonne at web.de> wrote:
> Will McDonald wrote:
> > Hi all.
> >
> > I'm writing a little script that operates on either stdin or a file
> > specified on the command line when run. I'm trying to handle the
> > situation where the script's run without any input gracefully but
> > can't think how to test for stdin.
> maybe http://docs.python.org/lib/module-fileinput.html is useful for you:

That looks ideal, I'll have a play with it to see how it behaves in
conjunction with getopt. Thanks Roland. Thanks Peter and Diez for your
input too.


More information about the Python-list mailing list