A high-level cross-platform API for terminal/console access

Peter Brittain peter.brittain.os at gmail.com
Thu Oct 22 05:02:28 EDT 2015


On Wednesday, October 21, 2015 at 11:26:40 PM UTC+1, eryksun wrote:
> 
> Also check out the curses module that's available on Christoph Gohlke's site:
> 
>     http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses

Neat.  I wasn't aware of this library of wheel installations.  I'll have a look at how that works out and see if I can rationalize my mapping code.  

First impression is that this might be tricky, though, as I've had issues with older Linux distributions using ncurses 5 and so handling 256 colour modes has been difficult due to limits on colour pairs.  This meant I had to fall back to looking up and using codes in the terminfo database using tigetstr.  According to the PDcurses docs, these APIs are all just stubs that return an error and so I'll probably need a curses and PDcurses mapping layer from the looks of things - which is not much better than a curses and win32 mapping layer.

I'm also still not convinced that curses package is the right API to expose for Python.  While ncurses does a great job of abstracting away the issues of terminal inter-operation, the Python curses package is just a thin wrapper of that C library and, as can be seen above, not truly cross-platform due to the restrictions of PDcurses.

Shouldn't we have a higher level simplification?  Something that hides away all the complexity of handling all these different platforms and so exposes a simple API?  One that humans can use without worrying about these issues?



More information about the Python-list mailing list