0

Is there anyway of clearing text in IDLE, its really anoying when i run the script a couple of times and then there's a cluster of words which is really hard to read.

and yes I have looked on google, stack_overflow and a couple of more websites but i cant find anything useful.

I tried to do:

import os
def cls():
    os.system("cls")
>>>cls()                      
braX
  • 11,506
  • 5
  • 20
  • 33
rZero3
  • 1,659
  • 1
  • 12
  • 8

2 Answers2

0

If you mean using the actual IDLE shell, I don't think there's any way to do it. IDLE is not meant to run programs from, it's just supposed to be a development tool. If you want to run programs from terminal or cmd, you can clear the text easily.

Use this instead:

os.system("clear") # or "cls" on windows

or

subprocess.call('clear') # or "cls" on windows  

To fake it in IDLE, you can use something like:

print("\n" * 50)
Charles Clayton
  • 17,005
  • 11
  • 87
  • 120
0
from subprocess import call as c

def cls():

    c("cls",shell=True)

print([x for x in range(10000)])

cls()

Whenever you wish to clear console call the function cls, but note that this function will clear the screen in Windows only if you are running Python Script using cmd prompt, it will not clear the buffer if you running by IDLE.

Akash Rana
  • 3,685
  • 3
  • 19
  • 28