Thread: Clear Screen

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    57
    Rep Power
    11

    Clear Screen


    Hi
    How do i clear display screen.

    I know they use cls in "C" programme but in python ?
  2. #2
  3. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    13
    Dos box or terminal display?
    GUI Tkinter,wxPython,PyQt ......?
    Windows or Linux?
    Which variant of C uses "cls"?

    Help us to help you

    Grim
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    57
    Rep Power
    11

    clear screen


    Sorry it's clrscr()
    in (turbo c)
  6. #4
  7. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,607
    Rep Power
    4247
    Code:
    def clrscr():
     	for i in range(1, 50):
     		print
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  8. #5
  9. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Comfused, where did the

    Code:
    def clrscr():
     	for i in range(1, 50):
     		print
    come into it . If you search the forums there were some previous threads about this although i think the genenal idea was to use a system command to clear the console - unless where talking about curses in which case you want to look at the curses module:

    http://www.python.org/doc/2.3.3/lib/module-curses.html

    EDIT: got ya now, move everything off the screen . Nice idea heheh. You could also use \b about a million times

    Mark.
    Last edited by netytan; April 27th, 2004 at 09:29 PM.
    programming language development: www.netytan.com Hula

  10. #6
  11. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,607
    Rep Power
    4247
    Yep, the trouble with using os.system() is that while system() itself is portable, the command you're running isn't necessarily portable. For DOS, it is called "cls" and for *nix, it is called "clear". Who knows what it is going to be on some other OS. Same with the curses module, which only works on *nix terminals.

    This clrscr() function might be a bit naive, but I guess it should work on anything that can print. Might need to increase the range of the loop though .
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo

IMN logo majestic logo threadwatch logo seochat tools logo