How to clean Python shell in IDLE

I run a script that uses a module that prints a lot of things on the screen, and I run out of RAM.
I can not get the module to write nothing. Python Shell stores absolutely everything, and I want to clear it.
To such questions, the only answer I could find was to write os.system('cls') (on Windows), but it does not delete anything.
Is there a way to clear my Python shell or limit its size?
thanks


Edit
Well, this question was marked as a duplicate, and I am asked to clarify why this is not so. I maintain that os.system('cls') does not work, while the answer to the question that I support, I repeat, should write os.system('cls') .

+4
source share
3 answers

With python shell, do you mean IDLE? Some quick searches suggest that IDLE does not have a clear screen, although many people seem to want this. If it is in the shell, then I am surprised that "cls" does not work.

If you enjoy working in Idle, you can look at this for the necessary functionality: http://idlex.sourceforge.net/extensions.html#ShellEnhancements The Internet seems to think that you should just stop using IDLE, however.

+4
source

How do you use a script? Do you call it from the shell? If so, you can redirect all the output to a file as follows:

 python my_script.py > /out/to/some/path.log 
+2
source

If the module just prints, you can use this:

 import sys sys.stdout = open('/dev/null', 'a') # or a real file, if you care about output. 
+2
source

Source: https://habr.com/ru/post/1489561/


All Articles