Clearing the screen

I

Ishwor

Hi i use IDLE to code Python in my machine. What i haven't been able
to do is call an in-built function called clear()/cls()/clr() because
it mightn't exist. so what i did is coded my own function called cls()
as such for i in range(1,40):
print " ";

now that does the job very nicely and i get cleared screen but what i
really want to achieve it everytime i start IDLE, without importing
any module, i want to be able to do just cls() and be able to clear
the screen. Is that achievable? Does that have mean i have to tinker a
bit with in-builts??

Thank you.
 
L

Lars

Hi Iswor,

If I understand you correctly then your program is writing output to a
console/terminal window and you want to clear that window.
I don't know of any library methods for that, but you might just do:

os.system("cls") #for windows
or
os.system("clear") #for unix
Not the most advanced solution though.
 
I

Ishwor

Hi Iswor,

If I understand you correctly then your program is writing output to a
console/terminal window and you want to clear that window.
I don't know of any library methods for that, but you might just do:

well i am not doing any console i/o. Just simple one. i am trying to
clear the IDLE (one of python IDE distributed with the original
distribution) screen which is pretty easy but having to doeverytime is boring (2 lines of boredom!!) so what i want is to be
able to do justand nothing more or even less!! ;-)
os.system("cls") #for windows
or
os.system("clear") #for unix
yeah i have used the 'os' module's system() method but that wasn't what i meant.
Not the most advanced solution though.
;-) Thanx anyway mate.

[snip]
 
C

Craig Ringer

well i am not doing any console i/o. Just simple one. i am trying to
clear the IDLE (one of python IDE distributed with the original
distribution) screen which is pretty easy but having to do
everytime is boring (2 lines of boredom!!) so what i want is to be
able to do just

and nothing more or even less!! ;-)

Assuming cls.cls() does the job for you, just add 'from cls import cls'
to your pythonrc ( ${HOME}/.pythonrc on UNIX , NFI on windows ).

On a side note, it'd be easier to read your post if you'd use the shift
key more often :p
 
A

Artur M. Piwko

In the darkest hour on Sat, 25 Dec 2004 09:41:54 +1030,
Ishwor said:
for i in range(1,40):
print " ";

Slightly ot, but perhaps this'll work for you:

def cls():
print "\033[2J"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top