Does one have to use curses to read single characters from keyboard?

DFS nospam at dfs.com
Sun Dec 11 07:37:56 EST 2022


On 12/11/2022 5:09 AM, Chris Green wrote:
> Is the only way to read single characters from the keyboard to use
> curses.cbreak() or curses.raw()?  If so how do I then read characters,
> it's not at all obvious from the curses documentation as that seems to
> think I'm using a GUI in some shape or form.
> 
> All I actually want to do is get 'Y' or 'N' answers to questions on
> the command line.
> 
> Searching for ways to do this produces what seem to me rather clumsy
> ways of doing it.


resp = 'x'
while resp.lower() not in 'yn':
     resp = input("Did you say Y or did you say N?: ")






More information about the Python-list mailing list