Why is there no platform independent way of clearing a terminal?

Terry Reedy tjreedy at udel.edu
Tue Jul 27 14:01:00 EDT 2010


On 7/27/2010 12:58 PM, Daniel Fetchinson wrote:

> After getting the technicalities out of the way, maybe I should have asked:
>
> Is it only me or others would find a platform independent python API
> to clear the terminal useful?

One problem is, Where would you put it? The OS module is for system 
calls, mostly based on posix. The system call involved in clearing a 
terminal is a write string call. *nix puts terminal control in a 
separate library.

Another is, what next? clear_line? Pretty soon, we are back to curses.

Still another problem is that most of us do not have terminals; we have 
screens and use them as such. OS-independent full-screen graphics/game 
libraries have clear screen commands. Similary, GUI systems have means 
of clearing text and canvas widgets, but should not be able to clear the 
whole screen. The turtle module has a clear command for its canvas, 
which would be the same regardless of underlying gui. So we already have 
several OS independent clear commands.

On Windows, the DOS clr command only works withing a text-mode command 
window (once called a dos window). The same thing (os.system('clr') 
within an IDLE shell uselessly flashes a blank command window, which 
then disappears. Yeah, it is too bad windows did not use the obvious 
'clear' like everyone? else. If command windows still imitate or can be 
set to imitate ansi terminals, then I would think curses is your best bet.

-- 
Terry Jan Reedy




More information about the Python-list mailing list