I'm running a script that uses a module that prints a lot of things on screen and I'm running out of RAM.
I can't make the module not to write anything for now.
The Python Shell stores absolutely everything and I want to clear it.
On similar questions the only answer I could find was to write os.system('cls')
(on Windows), but it doesn't delete anything.
Is there a way to clear the Python Shell or to limit its size?
Thanks
Edit.
Well, this question was marked as duplicate and I am asked to clarify why it isn't.
I state that os.system('cls')
doesn't work, while the answer to the question I supoosedly duplicate is to write os.system('cls')
.
The commands used to clear the terminal or Python shell are cls and clear.
>>> cls = Cls() >>> cls # this will clear console.
By python shell, do you mean IDLE? Some quick googling suggests that IDLE doesn't have a clear screen even though lots of people seem to want one. If it's in a shell, then I'm surprised 'cls' isn't working.
If you like working in Idle, you might look at this for getting the functionality you want: http://idlex.sourceforge.net/extensions.html#ShellEnhancements The internet seems to think you should just stop using IDLE, however.
How are you running the script? Are you calling it from a shell? If so, you can redirect all output to a file like this:
python my_script.py > /out/to/some/path.log
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With