Can Python clear a DOS screen?

D-Man dsh8290 at rit.edu
Fri Jan 19 12:51:55 EST 2001


On Thu, Jan 18, 2001 at 10:22:56PM +0000, Fredrik Lundh wrote:
| Dan Rolander wrote:
| > I've got a Python script that writes to a DOS console. Is it possible to
| > have the script clear the screen?
| 
|     os.system("cls")
| 
| (it's as stupid as it looks, but it works everywhere.

If by "everywhere" you mean "everywhere that is using DOS", then yes.
If the interpreter picks up my aliases/functions from bash (in Linux,
Solaris, etc) then it will work (I prefer typing "cls" instead of
"clear").


If removing text from the visible screen is your goal the following
(albeit stupid) loop can do it as well


for i in xrange( 500 ) :
	print


-D





More information about the Python-list mailing list