Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #88: Boss' kid fucked up the machine


comp / comp.lang.python / Re: Fwd: IDLE: clearing the screen

SubjectAuthor
o Re: Fwd: IDLE: clearing the screenCameron Simpson

1
Subject: Re: Fwd: IDLE: clearing the screen
From: Cameron Simpson
Newsgroups: comp.lang.python
Date: Wed, 5 Jun 2024 03:09 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: cs@cskk.id.au (Cameron Simpson)
Newsgroups: comp.lang.python
Subject: Re: Fwd: IDLE: clearing the screen
Date: Wed, 5 Jun 2024 13:09:29 +1000
Lines: 20
Message-ID: <mailman.89.1717556981.2909.python-list@python.org>
References: <0b2a163c-6e83-4739-960d-35a038d4ff0b@btinternet.com>
<Zl/W6bLq8zkT9pKj@cskk.homeip.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de eUthc05ghXGfaOWEwHK1GASFRIT+ADvIDPkGgDD9ap1w==
Cancel-Lock: sha1:tp9m5p5EqJ8SKoVsOQJoKHcOTR4= sha256:qYIKM+SowYanY2uQRVNa3EedrAsT7wMEKZ9wDa04dM4=
Return-Path: <cameron@cskk.id.au>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.002
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'def': 0.04; 'containing':
0.05; 'cc:addr:python-list': 0.09; 'expression': 0.09; 'idle':
0.09; 'prints': 0.09; 'skip:x 10': 0.09; 'subject:IDLE': 0.09;
'cc:name:python': 0.16; 'from:addr:cs': 0.16;
'from:addr:cskk.id.au': 0.16; 'from:name:cameron simpson': 0.16;
'ide,': 0.16; 'message-id:@cskk.homeip.net': 0.16;
'received:13.237': 0.16; 'received:13.237.201': 0.16;
'received:13.237.201.189': 0.16; 'received:cskk.id.au': 0.16;
'received:id.au': 0.16; 'received:mail.cskk.id.au': 0.16;
'subject:screen': 0.16; 'wrote:': 0.16; 'cc:addr:python.org':
0.20; 'returns': 0.22; 'cc:2**0': 0.25; 'subject:Fwd': 0.26;
"isn't": 0.27; 'function': 0.27; 'header:User-Agent:1': 0.30;
'fine.': 0.32; 'header:In-Reply-To:1': 0.34; 'received:au': 0.35;
"it's": 0.37; 'prompt': 0.39; 'ide': 0.40; 'whenever': 0.40;
'should': 0.40; 'skip:o 10': 0.61; 'clear': 0.64; 'received:13':
0.64; 'your': 0.64; 'top': 0.65; 'received:userid': 0.66;
'result,': 0.69; 'extra': 0.84; 'rob': 0.84; 'so:': 0.84
Mail-Followup-To: Rob Cliffe <rob.cliffe@btinternet.com>,
Python <python-list@python.org>
Content-Disposition: inline
In-Reply-To: <0b2a163c-6e83-4739-960d-35a038d4ff0b@btinternet.com>
User-Agent: Mutt/2.2.7 (2022-08-07)
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <Zl/W6bLq8zkT9pKj@cskk.homeip.net>
X-Mailman-Original-References: <0b2a163c-6e83-4739-960d-35a038d4ff0b@btinternet.com>
View all headers

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.

1

rocksolid light 0.9.8
clearnet tor