Re: Fwd: IDLE: clearing the screen

Liste des GroupesRevenir à cl python 
Sujet : Re: Fwd: IDLE: clearing the screen
De : rob.cliffe (at) *nospam* btinternet.com (Rob Cliffe)
Groupes : comp.lang.python
Date : 05. Jun 2024, 23:16:13
Autres entêtes
Message-ID : <mailman.92.1717625777.2909.python-list@python.org>
References : 1 2 3
User-Agent : Mozilla Thunderbird
On 05/06/2024 04:09, Cameron Simpson wrote:
On 04Jun2024 22:43, Rob Cliffe <rob.cliffe@btinternet.com> wrote:
import os
def cls(): x=os.system("cls")
>
Now whenever you type
cls()
it will clear the screen and show the prompt at the top of the screen.
>
(The reason for the "x=" is: os.system returns a result, in this case 0.  When you evaluate an expression in the IDE, the IDE prints the result.  So without the "x=" you get an extra line at the top of the screen containing "0".)
>
Not if it's in a function, because the IDLE prints the result if it isn't None, and your function returns None. So:
>
    def cls():
        os.system("cls")
>
should be just fine.
Yes, you're right.
Rob Cliffe

Date Sujet#  Auteur
6 Jun 24 o Re: Fwd: IDLE: clearing the screen1Rob Cliffe

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal