469,353 Members | 2,121 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,353 developers. It's quick & easy.

screen clear question

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

Thanks.

Jim C
Jul 18 '05 #1
6 21967
On Sun, 2005-01-02 at 11:31, jcollins wrote:
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.

--
Craig Ringer

Jul 18 '05 #2
import os

# windows
os.system("cls")

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

That's all I can account for.

Daniel Bickett
Jul 18 '05 #3
On Sun, 02 Jan 2005 14:23:07 +0800, Craig Ringer
<cr***@postnewspapers.com.au> wrote:
On Sun, 2005-01-02 at 11:31, jcollins wrote:
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.


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
Jul 18 '05 #4
Alan Gauld wrote:
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.

--
Nick Coghlan | nc******@email.com | Brisbane, Australia
---------------------------------------------------------------
http://boredomandlaziness.skystorm.net
Jul 18 '05 #5
On Mon, 03 Jan 2005 02:15:23 +1000, Nick Coghlan
Alan Gauld wrote:
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.


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
Jul 18 '05 #6
Nick Coghlan wrote:
Alan Gauld wrote:
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.

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: ar*****@townisp.com
Ur: http://shardservant.no-ip.info
Jul 18 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

19 posts views Thread by Dave | last post: by
3 posts views Thread by Miki Tebeka | last post: by
18 posts views Thread by Tim Mierzejewski | last post: by
51 posts views Thread by someone | last post: by
11 posts views Thread by Rajendran | last post: by
10 posts views Thread by Kenneth Lantrip | last post: by
65 posts views Thread by Leslie Kis-Adam | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.