How to input one char at a time from stdin?
Swaroop C H
swaroopch at gmail.com
Tue Jan 25 14:45:10 EST 2005
On Tue, 25 Jan 2005 12:38:13 -0700, Brent W. Hughes
<brent.hughes at comcast.net> wrote:
> I'd like to get a character from stdin, perform some action, get another
> character, etc. If I just use stdin.read(1), it waits until I finish typing
> a whole line before I can get the first character. How do I deal with this?
This is exactly what you need:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/134892
Title: "getch()-like unbuffered character reading from stdin on both
Windows and Unix"
This recipe was a lifesaver for me once :-)
Regards,
--
Swaroop C H
Blog: http://www.swaroopch.info
Book: http://www.byteofpython.info
More information about the Python-list
mailing list