[Tutor] clear screen inside python interpreter

Nick Raptis airscorp at otenet.gr
Fri Aug 7 01:06:23 CEST 2009


I don't think there's a Python command to do this.

You can always print enough newlines to clear your view of the window:

print "\n" * 80

or use os.system to issue a command the shell/terminal/cmd will understand

import os
os.system("cls")

or

import os
os.system("clear")


I resently made a 'game of life' clone and used the first method to 
clear the screen. It's good enough for many things!

Nick


Monte Milanuk wrote:
> Okay, simple question: is there anything similar to to 'clear' or 
> 'cls' to clean up a console window full of commands in the python 
> shell?  Short of exiting and restarting the interpreter I'm not having 
> a lot of luck here.
>
> Thanks,
>
> Monte
> ------------------------------------------------------------------------
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>   


More information about the Tutor mailing list