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

Laura Creighton lac at openend.se
Thu Oct 22 05:23:42 EDT 2015


In a message of Thu, 22 Oct 2015 02:02:28 -0700, Peter Brittain writes:
>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?
>-- 
>https://mail.python.org/mailman/listinfo/python-list

Fredrik Lundh's console implementation
http://effbot.org/zone/console-handbook.htm
might be of interest in that case, but I think it is 'old versions
of windows only'.  But it's a different take on the abstraction 
problem.  I haven't used it for something like 15 years now, though,
so can barely remember it ...

Laura



More information about the Python-list mailing list