Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any way to clear python's IDLE window?

I know there's a similar topic about python console, but I do not know if they are the same. I tried system("clear") and it didn't work here.

How do I clear python's IDLE window?

like image 294
devoured elysium Avatar asked Sep 16 '09 11:09

devoured elysium


People also ask

How do you clear Python history?

If your system doesn't use readline , to remove all Python command history just delete the history file at ~/. python_history . You can see the full path of the history file with: python -c "import os; print(os.

How do I clear the Python shell editor?

The commands used to clear the terminal or Python shell are cls and clear.


2 Answers

The "cls" and "clear" are commands which will clear a terminal (ie a DOS prompt, or terminal window). From your screenshot, you are using the shell within IDLE, which won't be affected by such things. Unfortunately, I don't think there is a way to clear the screen in IDLE. The best you could do is to scroll the screen down lots of lines, eg:

print ("\n" * 100) 

Though you could put this in a function:

def cls(): print ("\n" * 100) 

And then call it when needed as cls()

like image 159
Brian Avatar answered Sep 29 '22 08:09

Brian


os.system('clear') works on linux. If you are running windows try os.system('CLS') instead.

You need to import os first like this:

import os 
like image 37
Nadia Alramli Avatar answered Sep 29 '22 08:09

Nadia Alramli