STDIO Questions.

euler27182 at my-deja.com euler27182 at my-deja.com
Mon Nov 13 17:30:11 EST 2000


I'm new to Python, and just wondered about the following peculiarities under
Windows version 1.6 of Python:   sys.stdin.read(1) ...Always waits for the
carriage return, displaying as many characters as are typed.  Though it does
return the specified number of characters, I would expect this function to
return execution immediately with a null character if no keystroke has been
made.  If I wanted to see a whole line, I would use the .readline() function
instead.  How would I implement a stateless keybuffer read (to catch nulls as
well)?  I've commonly used this functionality in BASIC and assembly to
periodically poll for user input without stopping execution in the main loop,
but don't see how to in Python.   Why doesn't IDLE have a .read() function in
the interactive interpreter, to allow input from stdin?   If I try to
redirect stdout to a null file (which has a dummy write function), the
sys.stdin.read(1) function still echoes keystrokes to stdout. Is there any
possible way to suppress echoing (for password input from the user)?  


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list