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

Christian Gollwitzer auriocus at gmx.de
Fri Oct 28 03:51:52 EDT 2016


Am 28.10.16 um 09:33 schrieb Marko Rauhamaa:
> Christian Gollwitzer <auriocus at gmx.de>:
>> I still believe that it is not a "basic functionality". You need it,
>> if you want to program a text editor or similar thing, but without
>> using a real GUI. This is a small niche.
>
> I disagree. It's a very large group of programs. For example, CPython's
> input() function puts the terminal in character mode to support
> emacs-style editing keys on Linux. And of course, CPython's REPL reader
> does it as well.
>
> CPython does that via GNU readline:
>
>    <URL: https://docs.python.org/3/library/readline.html>

You are right, readline is a very important application that uses raw 
terminal input. What Bart is complaining, currently you can't easily 
implement something like readline in Python from scratch - where you 
intercept all keystrokes - as opposed to using readline as it is. I am 
just not convinced that so many people need to implement something like 
readline.

>> It is both easier and more functional to use a real GUI library.
>
> Well, CPython doesn't do that...

But it doesn't intercept each keystroke, either. You could argue that 
readline IS a "GUI" library, and you get all the benefits from using it 
- it is used in multiple places, so the user is familiar with it, you 
don't need to fiddle with low-leve stuff like different terminal escape 
sequences etc.

	Christian




More information about the Python-list mailing list