IDLE: clearing the screen

Michael F. Stemper michael.stemper at gmail.com
Mon Jun 10 09:55:20 EDT 2024


On 08/06/2024 14.18, Rob Cliffe wrote:
> OK, here is the advanced version:
> import os
> class _cls(object):
>      def __repr__(self):
>          os.system('cls')
>          return ''
> cls = _cls()
> 
> Now when you type
> cls
> it clears the screen.  The only flaw is that there is a blank line at the very top of the screen, and the ">>>" prompt appears on the SECOND line.
> (This blank line is because the IDLE prints the blank value returned by "return ''" and adds a newline to it, as it does when printing the value of any expression.)

Why have it return anything at all?

-- 
Michael F. Stemper
Indians scattered on dawn's highway bleeding;
Ghosts crowd the young child's fragile eggshell mind.



More information about the Python-list mailing list