1

Can I clear the screen of IDLE interactive mode in Windows? I tried with the following code which fails to work:

import os
os.system('cls')

The cls command works only in Windows terminal(command prompt) and it doesn't work in IDLE screen.

Is there any other way? Or first of all, is there any hope to clear that IDLE interactive mode???

  • Unfortunately (after taking a peek at IDLE's internals too), it looks like there is no way to clear the console. – AKX Jun 30 '20 at 09:36

3 Answers3

1

cls and clear are commands which will clear a terminal (ie a DOS prompt, or terminal window). If you are using the shell within IDLE, which won't be affected by such things, a workaround might be to print a lot of empty lines with print("\n" * 100). See also this answer for more information.

Ruben Helsloot
  • 12,582
  • 6
  • 26
  • 49
Ankit Sharma
  • 164
  • 8
0

No, it is not possible, neither in IDLE, nor in Python command prompt.

Use IPython instead with its “magic” command %cls (and many others), preferable as a part of some IDE which utilized it, for example Spyder, PyCharm or JupyterLab.

Anaconda contains both Spyder and JupyterLab and many Python packages, it's probably the best all-in-one solution.

MarianD
  • 13,096
  • 12
  • 42
  • 54
-1

You can from os import system and then system("cls") this will just clear out the screen. have fun coding:).

Jas0n
  • 91
  • 1
  • 2
  • 10