On Dec 2, 2:04 pm, Hans Mulder wrote:
> That's odd. For some reason, I can get away with a simple
>
> sys.stdin = open('/dev/tty')
>
> and raw_input will merrily read from file descriptor 3.
>
> I'm using Pyhton 2.7.1 and 3.2 on MacOS/X 10.5.0.
>
> What version are you using?
>
> -- HansM
On 2/12/11 10:09:17, janedenone wrote:
I had tried
sys.stdin = open('/dev/tty', 'r')
That seems to work for me. This code:
import sys
if sys.version_info.major == 2:
input = raw_input
for tp in enumerate(sys.stdin):
print("%d: %s" % tp)
sys.stdin = open('/dev/tty', 'r')
answer = i
On Dec 2, 8:53 am, Hans Mulder wrote:
> On 2/12/11 03:46:10, Dan Stromberg wrote:
>
> > 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.
>
> Read
On 2/12/11 03:46:10, Dan Stromberg wrote:
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.
Reading from /dev/tty works fine on OS/X.
-- HansM
--
ht
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_inp
On 12/01/2011 11:01 AM, 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()
With above line you said, that you want to read ALL data from stdin, so
it's obvious that any following command will be unable
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 reope