Re: Reading twice from STDIN



On 12/1/11, janedenone <janedenone@xxxxxxxxxxxxxx> 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

.



Relevant Pages

  • Re: Help parsing body text
    ... You must find the delimiter for columns and rows. ... use the function again for every row to split by the Pipe. ... I wonder if anyone could get me started on how to parse the text body ... calendar reminder to be sent to the person. ...
    (microsoft.public.office.developer.outlook.vba)
  • Reading twice from STDIN
    ... I would like to read from a pipe, parse the input and ask the user ... accomplished with Python 2.7 on a current Mac. ...
    (comp.lang.python)
  • Re: Mask Gang Slay
    ... Harlan Messinger wrote: ... > I couldn't help but think of Ron this weekend when I was up in New ... > pipe and parse it. ...
    (sci.lang)
  • parse postfix stream
    ... I would like to use the postfix-command ... test unix - n n - 1 pipe ... Now i have to parse the mail with perl. ...
    (comp.lang.perl.misc)