[Python-ideas] Remove tty module

Andrew Barnert abarnert at yahoo.com
Thu Jul 25 17:58:29 CEST 2013


On Jul 25, 2013, at 10:08, Clay Sweetser <clay.sweetser at gmail.com> wrote:

> 
> On Jul 24, 2013 7:08 AM, "Andrew Barnert" <abarnert at yahoo.com> wrote:
> >
> > On Jul 24, 2013, at 11:01, "M.-A. Lemburg" <mal at egenix.com> wrote:
> >
> > > On 24.07.2013 10:43, anatoly techtonik wrote:
> > >> http://hg.python.org/cpython/file/74fd1959cf44/Lib/tty.py
> > >>
> > >> tty module is cryptic. The low level interface it is exposed can be
> > >> covered by appropriate recipes in termios module documentation. You
> > >> can't understand tty without understanding termios. You also can't
> > >> understand tty without being a Unix guru -
> > >> http://en.wikipedia.org/wiki/TTY I doubt that raw mode function (which
> > >> is 50% of this stuff) is really used by anyone.
> >
> > Many novices want a way to read a character from the tty without waiting, to create simple keyboard menus or just "press any key to continue" apps without using curses or a GUI app.
> >
> > It would be even nicer if there were an easier way to do this (especially one that worked on both unix and windows); it's a pretty common question on StackOverflow and people are always disappointed at how complicated the answer is. But making it even harder is probably not a good idea.
> 
> Yeah, I'm with you on the windows compatibility; It's always annoyed me that tty and termios (along with most of curses) is Unix only, when I'm fairly sure that windows has enough functionality in it's api that replication is possible. Still, I'm no expert on Window's api, so I may be wrong.
> 
IIRC, there are two different curses near-clones for Windows, so it's obviously possible. But unless Python included one of them, a wrapper wouldn't be that useful.

Faking termios on Windows (and presumably faking attributes for the cmd.exe console window) would probably be almost as much work as faking curses, and a lot less useful, so I'm not sure that would be worth doing.

Also, the serial port stuff isn't as easy to integrate with the tty stuff on Windows. I think a separate module (which could also do things like enumerating serial files--which is also nontrivial on Macs and some other Unix systems) might be more useful than trying to do it together with tty.

Just raw and echo flags on and off on stdin might be sufficient (together with isatty and a way to get the binary file underneath stdin, both of which we already have)?

Or even just a single raw_read(maxcount=1) function? Switching back and forth for each read wouldn't exactly be super-efficient (especially if the tty is actually a 1200 baud SLIP or PPP or something--is that ever an issue nowadays?), but it would be very easy to implement, and novice-friendly.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130725/e8dcdb4a/attachment.html>


More information about the Python-ideas mailing list