Re: Fwd: IDLE: clearing the screen

2024-06-05 Thread Rob Cliffe via Python-list



On 05/06/2024 04:09, Cameron Simpson wrote:

On 04Jun2024 22:43, Rob Cliffe  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

--
https://mail.python.org/mailman/listinfo/python-list


Re: From JoyceUlysses.txt -- words occurring exactly once

2024-06-05 Thread Grant Edwards via Python-list
On 2024-06-05, dn via Python-list  wrote:

> If you/your teacher can't define a "word", the code, any code, will 
> almost-certainly be wrong!

Back when I was a student...

When there was a homework/project assignemnt with a vague requirement
(and it wasn't practical to get the requirement refined), what always
worked for me was to put in the project report or program comments or
somewhere a statement that the requirement could be interpreted in
different ways and here is the precise interpretation of the
requirement that is being implemented.



-- 
https://mail.python.org/mailman/listinfo/python-list