Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.chainon-marquant.org!news-transit.tcx.org.uk!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '(at': 0.03; 'raises': 0.07; 'python': 0.08; '2.7': 0.13; "'not": 0.16; 'from...': 0.16; 'next:': 0.16; 'normally.': 0.16; 'parsed': 0.16; 'pipe,': 0.16; 'piped': 0.16; 'cc:addr:python-list': 0.16; 'received:74.125.82.44': 0.16; 'received:mail-ww0-f44.google.com': 0.16; 'wrote:': 0.18; 'jan': 0.19; 'cc:no real name:2**0': 0.20; 'input': 0.22; 'header:In-Reply-To:1': 0.22; 'cc:2**0': 0.24; 'there.': 0.24; 'tried': 0.27; 'url:mailman': 0.28; 'urls': 0.28; 'message-id:@mail.gmail.com': 0.28; 'worked': 0.29; 'cc:addr:python.org': 0.29; 'seemingly': 0.30; 'least': 0.30; 'hi,': 0.32; 'list': 0.32; 'url:listinfo': 0.32; 'calling': 0.34; 'parse': 0.34; 'surprised': 0.34; 'received:74.125.82': 0.35; 'something': 0.35; 'url:python': 0.36; 'but': 0.37; 'received:74.125': 0.37; 'received:google.com': 0.37; 'open': 0.38; 'subject:from': 0.38; 'url:org': 0.39; 'missing': 0.40; 'choose': 0.62; 'mac.': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=MNNvQKhs/fwEmBtaBjpKA6cxDqMSpDnADqjqh+ivhcc=; b=t/9LIYpOGpH+QWgHIVjddiES5sYVBDOL7gkquNST0oIfHlEMlwmSNbY1jkDpjySsq6 dmdGMzDRxlH8SWuJCUyk5mhYDDJzcedWDMDRQhI1jN4dV2bgV1NpANcjSyTDRumR8kpB gATo1IXWKr/mDNUSlXQ/WYoU/Q7wmfO+80Wuk= MIME-Version: 1.0 In-Reply-To: <6de9515a-17b2-40a3-a113-5733cad9f794@cu3g2000vbb.googlegroups.com> References: <6de9515a-17b2-40a3-a113-5733cad9f794@cu3g2000vbb.googlegroups.com> Date: Thu, 1 Dec 2011 18:46:10 -0800 Subject: Re: Reading twice from STDIN From: Dan Stromberg To: janedenone Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1322793980 news.xs4all.nl 6951 [2001:888:2000:d::a6]:35737 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:16520 On 12/1/11, janedenone 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 >