stdin: processing characters

Edward Elliott nobody at 127.0.0.1
Thu Apr 27 20:45:50 EDT 2006


Kevin Simmons wrote:
> I have a python script that prompts the user for input from stdin via a
> menu. I want to process that input when the user types in two characters
> and not have to have the user press <CR>. As a comparison, in the bash
> shell one can use (read -n 2 -p "-->" CHOICE; case $CHOICE in...). Works
> great and is very

I did something like this a couple years ago, curses was the easiest way I
found to do it.  It's pretty painless with the wrapper function, which
restores your terminal on error/exit.




More information about the Python-list mailing list