Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #16520
| References | <6de9515a-17b2-40a3-a113-5733cad9f794@cu3g2000vbb.googlegroups.com> |
|---|---|
| Date | 2011-12-01 18:46 -0800 |
| Subject | Re: Reading twice from STDIN |
| From | Dan Stromberg <drsalists@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3212.1322793980.27778.python-list@python.org> (permalink) |
On 12/1/11, janedenone <janedenone@googlemail.com> wrote:
> Hi,
>
> I would like to read from a pipe, parse the input and ask the user
> what to do next:
>
> message = sys.stdin.read()
> # message is parsed and URLs are printed as a list to choose from...
> selected_index = raw_input('Which URL to open?')
>
> Calling raw_input() always raises in an EOFError. I tried reopening
> and resetting sys.stdin, but nothing worked (at least on OX X 10.7,
> see
>
You can read piped data from sys.stdin normally. Then if you want
something from the user, at least on most *ix's, you would open
/dev/tty and get user input from there. 'Not sure about OS/X.
http://stackoverflow.com/questions/8034595/python-raw-input-following-sys-stdin-read-throws-eoferror).
>
> I am surprised to find that a seemingly trivial task cannot be
> accomplished with Python 2.7 on a current Mac. Or am I missing
> something simple?
>
> - Jan
> --
> http://mail.python.org/mailman/listinfo/python-list
>
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Reading twice from STDIN janedenone <janedenone@googlemail.com> - 2011-12-01 02:01 -0800
Re: Reading twice from STDIN Gelonida N <gelonida@gmail.com> - 2011-12-01 11:41 +0100
Re: Reading twice from STDIN Dan Stromberg <drsalists@gmail.com> - 2011-12-01 18:46 -0800
Re: Reading twice from STDIN Hans Mulder <hansmu@xs4all.nl> - 2011-12-02 08:53 +0100
Re: Reading twice from STDIN janedenone <janedenone@googlemail.com> - 2011-12-02 01:09 -0800
Re: Reading twice from STDIN Hans Mulder <hansmu@xs4all.nl> - 2011-12-02 14:04 +0100
Re: Reading twice from STDIN janedenone <janedenone@googlemail.com> - 2011-12-02 07:27 -0800
csiph-web