[Python-ideas] Remove tty module
Andrew Barnert
abarnert at yahoo.com
Wed Jul 24 13:02:17 CEST 2013
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.
So, maybe if we had a higher level "consoleio" module along with the low level termios we wouldn't need the mid level tty.
>> In ideal world the tty should be substituted with interface with less
>> cryptic terminology replacing cbreak mode, cooked mode, raw mode with
>> user oriented concepts. Otherwise this functionality is already
>> covered by termios interface.
I'm not sure providing the existing mid level functionality with friendlier but less standard (and therefore harder to look up) names would really help much.
> Better references:
> http://en.wikipedia.org/wiki/POSIX_terminal_interface
> http://en.wikipedia.org/wiki/Cooked_mode
>
> cbreak and raw modes are needed for e.g. games or editors that
> need low-level access to the keyboard.
>
> For a user oriented TTY interface, have a look at
> http://en.wikipedia.org/wiki/Ncurses and
> http://docs.python.org/2.7/library/curses.html
Curses is great, but sometimes you want raw io without it. For one thing, occasionally you need to deal with a platform that doesn't have curses (like iOS). But more generally, sometimes all you want is raw input, without console windowing and other fancy stuff--again, think of those novices with their "press any key to continue" apps. So, a very simple pure python library on top of unix termios and windows conio might be nice as well.
More information about the Python-ideas
mailing list