screen clear question

Discussion in 'Python' started by jcollins, Jan 2, 2005.

  1. jcollins

    jcollins Guest

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

    Thanks.

    Jim C
     
    jcollins, Jan 2, 2005
    #1
    1. Advertising

  2. jcollins

    Craig Ringer Guest

    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
     
    Craig Ringer, Jan 2, 2005
    #2
    1. Advertising

  3. import os

    # windows
    os.system("cls")

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

    That's all I can account for.

    Daniel Bickett
     
    Daniel Bickett, Jan 2, 2005
    #3
  4. jcollins

    Alan Gauld Guest

    On Sun, 02 Jan 2005 14:23:07 +0800, Craig Ringer
    <> 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
     
    Alan Gauld, Jan 2, 2005
    #4
  5. jcollins

    Nick Coghlan Guest

    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 | | Brisbane, Australia
    ---------------------------------------------------------------
    http://boredomandlaziness.skystorm.net
     
    Nick Coghlan, Jan 2, 2005
    #5
  6. jcollins

    Alan Gauld Guest

    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
     
    Alan Gauld, Jan 2, 2005
    #6
  7. 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:
    Ur: http://shardservant.no-ip.info
     
    Andrew Robert, Jan 5, 2005
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tshad

    Clear all fields on a screen

    tshad, May 19, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    2,292
    tshad
    May 20, 2005
  2. Boki
    Replies:
    5
    Views:
    11,665
    Darryl Pierce
    Apr 16, 2005
  3. owl
    Replies:
    2
    Views:
    889
  4. David

    Response.Clear() doesn't clear

    David, Jan 31, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    1,066
    Mark Fitzpatrick
    Jan 31, 2008
  5. InvalidLastName

    Unrecognized element 'add' after <clear></clear>

    InvalidLastName, Feb 26, 2007, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    1,004
    Steven Cheng[MSFT]
    Mar 6, 2007
Loading...

Share This Page