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

Christian Gollwitzer auriocus at gmx.de
Fri Oct 28 09:50:59 EDT 2016


Am 28.10.16 um 12:30 schrieb Marko Rauhamaa:
> Christian Gollwitzer <auriocus at gmx.de>:
>
>> Am 28.10.16 um 10:59 schrieb Marko Rauhamaa:
>>> I don't know. How would you implement "less" in Python? How would you
>>> implement "nethack" in Python?
>>
>> On my system:
>>
>> Apfelkiste:~ chris$ otool -L /usr/bin/less
>> /usr/bin/less:
>> 	/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0,
>> current version 5.4.0)
>> 	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
>> version 1225.0.0)
>>
>> So "less" in C uses ncurses.
>
> On mine (Fedora 24):
>
> ========================================================================
> $ ldd $(which less)
> 	linux-vdso.so.1 (0x00007ffdbbb79000)
> 	libtinfo.so.6 => /lib64/libtinfo.so.6 (0x00007f8d72678000)
> 	libc.so.6 => /lib64/libc.so.6 (0x00007f8d722b6000)
> 	/lib64/ld-linux-x86-64.so.2 (0x000055e31be7e000)
> ========================================================================
>
> Notably missing is: /usr/lib64/libncurses.so.6
>

Interesting. So your less does it in a different way than mine. I peeked 
into the sources, and it seems that less uses either tinfo, xcurses, 
ncursesw, ncurses, curses, termcap or termlib on nNix-like systems. On 
Windows it uses WIN32getch(). So there is no "one obvious way" to do 
this in C, but a large variety of options - just like in Python.

	Christian




More information about the Python-list mailing list