Why doesn't Python include non-blocking keyboard input function?

Marko Rauhamaa marko at pacujo.net
Tue Oct 25 08:43:05 EDT 2016


BartC <bc at freeuk.com>:

> Ctrl-C is not the same; that will just abort (without doing proper
> termination such as saving your data, or even just asking the user to
> confirm).

Ctrl-C is not the same, but it does let you intercept it and even ignore
it. Just handle signal.SIGINT.

> A very basic model of an interactive text-based computer has input at
> one end and output at the other. And a keyboard is the obvious choice
> for input (a bit easier than voice and less crude than punched cards
> or tape).

Text and keyboard are completely different entities. You don't find [F1]
or [Insert] or [Alt] in text nor do you distinguish between button up
and button down. Also, you can't measure the timing between the
characters in text.

Most Unix entities are right at home with text. It's the keyboard that's
problematic. The keyboard does not communicate with characters or text.
Rather it emits events with keycodes.


Marko



More information about the Python-list mailing list