Re: IDLE: clearing the screen

Liste des GroupesRevenir à cl python 
Sujet : Re: IDLE: clearing the screen
De : michael.stemper (at) *nospam* gmail.com (Michael F. Stemper)
Groupes : comp.lang.python
Date : 10. Jun 2024, 14:55:20
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v470k8$g26c$1@dont-email.me>
References : 1 2
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0
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.

Date Sujet#  Auteur
8 Jun 24 * Re: IDLE: clearing the screen4Rob Cliffe
10 Jun 24 `* Re: IDLE: clearing the screen3Michael F. Stemper
10 Jun 24  `* Re: IDLE: clearing the screen2Stefan Ram
10 Jun 24   `- Re: IDLE: clearing the screen1Michael F. Stemper

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal