blocking read on stdin on Windows?
jlearman at cisco.com
Sat Sep 4 17:23:12 CEST 2004
I want to do a very simple thing in Windows. (Using Python Shell.)
I want to write a prompt to sys.stdout and read the user input.
(Ideally, without waiting for a newline.)
Here are the problems I'm encountering. Newbie problems, no doubt.
sys.stdin.read() gives me an attribute error
sys.stdin.readline() doesn't block waiting for input. And even
if it did, it would block waiting for a newline.
I thought sys.stdin was supposed to behave like a File object.
In Python Shell it's actually idlelib.rpc.RPCProxy, but that's
understandable. But shouldn't it support read()?
And without termios (unavailable on Windows), how would I
set the file to nonblocking read mode? PyWin32 doesn't seem to
have any help, but I might just have missed it.
I assume a programming language & system would have a pretty
simple way to get input from the user!
PS: Python rocks. I've used it a lot, but so far only on UNIX,
and generally for filters or web scripts -- haven't needed to
ask any questions before.
More information about the Python-list