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

Grant Edwards grant.b.edwards at gmail.com
Thu Oct 27 00:26:42 EDT 2016


On 2016-10-27, Paul Rubin <no.email at nospam.invalid> wrote:
> Terry Reedy <tjreedy at udel.edu> writes:
>
>> Today, ethernet-connected *nix servers have no keyboard, mouse, or
>> even a directly connected terminal.
>
> Usually you ssh into them and connect to a pty which supports the
> same ioctls that a real terminal would.

On all the Unixes/Linuxs I know of, a pty supports a _subset_ of those
that a real tty supports.  The fact that some of them are missing has
annoyed me for decades because it prevents you from implementing a
serial port in user-space[1]. I've offered a few times to extend the
Linux pty driver to support the same set of ioctl calls that a tty
does (so that it could be used in place of a tty generally), but I've
never gotten any response.

> I use screen editors over ssh all the time, not to mention filters
> like "more" where you press the space bar to scroll to the next
> page.  It's sad that there's no easy way to do that in Python.

Yep, among the ioctl calls that ptys do support are those that allow
you to do raw and non-blocking input.

[1] The fact that Windows allows you to implement a serial port in
    userspace and Linux doesn't just adds insult to injury.

--
Grant





More information about the Python-list mailing list