screen clear question

J

jcollins

Is there a command in Python to clear the screen? That is without writing
multiple blank lines.

Thanks.

Jim C
 
C

Craig Ringer

Is there a command in Python to clear the screen? That is without writing
multiple blank lines.

Without knowing what 'screen' you're talking about, it's hard to say. If
you mean clearing a terminal, you can call 'tput clear' or
'/usr/bin/clear' on many UNIX systems; no idea about Windows.
 
D

Daniel Bickett

import os

# windows
os.system("cls")

# bash ( mac, linux )
os.system("clear")

That's all I can account for.

Daniel Bickett
 
A

Alan Gauld

Without knowing what 'screen' you're talking about, it's hard to say. If
you mean clearing a terminal, you can call 'tput clear' or
'/usr/bin/clear' on many UNIX systems; no idea about Windows.

On Windows the DOS CLS command will clear a command prompt, it
also works for CP/M and VAX terminals too. Finally I think the
curses module allows you to clear a window, including the main
window - ie the terminal screen.

In each case run CLS (or clear) via os.system()

But the bottom line is that there is no builtin command
because the mechanism is different on each platform.

Alan G.
Author of the Learn to Program website
http://www.freenetpages.co.uk/hp/alan.gauld
 
N

Nick Coghlan

Alan said:
But the bottom line is that there is no builtin command
because the mechanism is different on each platform.

I'd have said it was because the inpreter is line-oriented rather than
screen-oriented, but YMMV.

Cheers,
Nick.
 
A

Alan Gauld

But the bottom line is that there is no builtin command
because the mechanism is different on each platform.

I'd have said it was because the inpreter is line-oriented rather than
screen-oriented, but YMMV.[/QUOTE]

Yeah, that might be a reason as well :)

But then the early PC GW-Basic or BASICA interpreters were line
based too but both provided a CLS command because the *programs*
that were written were usually screen based... But they ran on a
single OS so a CLS was easily possible.

Alan G.


Author of the Learn to Program website
http://www.freenetpages.co.uk/hp/alan.gauld
 
A

Andrew Robert

Nick said:
I'd have said it was because the inpreter is line-oriented rather than
screen-oriented, but YMMV.

Cheers,
Nick.
I would try doing a test against the resident OS the program is running
against and set the clear command based on that.


--
Thank you,
Andrew Robert

E-mail: (e-mail address removed)
Ur: http://shardservant.no-ip.info
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top