SNQ: stdin with both a pipe and keyboard

Justin Shaw wyojustin at
Wed Jan 22 03:18:40 CET 2003

"Dennis Lee Bieber" <wlfraed at> wrote in message
news:5hr0g-4m3.ln1 at
> Michael Ressler fed this fish to the penguins on Tuesday 21 January
> 2003 11:35 am:
> >
> > I've been using to suck in the data, but if I then
> > use raw_input() or something like it to ask for the filename, I get an
> > EOF error; like raw_input() was already expecting the keyboard text to
> > be there without waiting for it.
> >
>         So far as I know, raw_input() reads via sys.stdin -- which means
it is
> trying to read your pipe which, after the data was already read in is
> at EOF.
>         I don't know enough to state if you can close and reopen sys.stdin
> redirect it back to the console.
>         Might be easier to design it to read the destination file name as
> command line argument and not prompt for it.

Or accept the output filename on the command line.  Then you could default
to stdout if no arg was present.

More information about the Python-list mailing list