[Python-ideas] Remove tty module

Andrew Barnert abarnert at yahoo.com
Fri Aug 2 08:03:25 CEST 2013


From: Andrew Barnert <abarnert at yahoo.com>

Sent: Thursday, August 1, 2013 9:47 PM


> From: "random832 at fastmail.us" <random832 at fastmail.us>
> Sent: Thursday, August 1, 2013 1:18 PM


>>  What about faking conio on Unix?
> 
> That's a great idea.


See https://github.com/abarnert/consoleio for a rough implementation.

You might even be able to "pip install git+https://github.com/abarnert/consoleio".

It does not work on Python 2.x, although I think it wouldn't be that hard to make it do so. It probably works on 3.0-3.2, but I haven't tested on anything earlier than 3.3.0. I also haven't tested on Windows, but if it doesn't work, it should be trivial to fix.

I went with the idea of only allowing consoleio functions inside an enabling() context (or explicit enable() and disable() calls) instead of switching on the fly. It makes khbit easier to implement and to use, and it's generally simpler, cleaner, and more efficient, and I don't think anyone will complain too much.

Anyway, if something like were added to the stdlib, it definitely wouldn't allow us to deprecate tty or termios (especially since it uses them… but even if it didn't, sometimes you need more flexibility), but it would allow us to add a note at the top saying "If you're using looking for simple, more-portable raw I/O, see the consoleio module."



More information about the Python-ideas mailing list