SNQ: stdin with both a pipe and keyboard

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


"Dennis Lee Bieber" <wlfraed at ix.netcom.com> wrote in message
news:5hr0g-4m3.ln1 at beastie.ix.netcom.com...
> Michael Ressler fed this fish to the penguins on Tuesday 21 January
> 2003 11:35 am:
>
> >
> > I've been using sys.stdin.read() 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
to
> redirect it back to the console.
>
>         Might be easier to design it to read the destination file name as
a
> 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.
Justin






More information about the Python-list mailing list