Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Clearing the screen

Reply
Thread Tools

Clearing the screen

 
 
Ishwor
Guest
Posts: n/a
 
      12-24-2004
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
>>> def cls():

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.

--
cheers,
Ishwor Gurung
 
Reply With Quote
 
 
 
 
Lars
Guest
Posts: n/a
 
      12-24-2004
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.
---
Happy holidays!
~Lars

 
Reply With Quote
 
 
 
 
Ishwor
Guest
Posts: n/a
 
      12-24-2004
On 24 Dec 2004 15:33:26 -0800, Lars <(E-Mail Removed)> wrote:
> 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 do
>>>import cls
>>> cls()

everytime is boring (2 lines of boredom!!) so what i want is to be
able to do just
>>>cls()

and 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]
--
cheers,
Ishwor Gurung
 
Reply With Quote
 
Craig Ringer
Guest
Posts: n/a
 
      12-25-2004
On Sat, 2004-12-25 at 07:43, Ishwor wrote:
> On 24 Dec 2004 15:33:26 -0800, Lars <(E-Mail Removed)> wrote:
> > 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 do


> >>>import cls
> >>> cls()


> everytime is boring (2 lines of boredom!!) so what i want is to be
> able to do just


> >>>cls()


> 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

--
Craig Ringer

 
Reply With Quote
 
Artur M. Piwko
Guest
Posts: n/a
 
      01-01-2005
In the darkest hour on Sat, 25 Dec 2004 09:41:54 +1030,
Ishwor <(E-Mail Removed)> screamed:
>>>> def cls():

> for i in range(1,40):
> print " ";
>


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

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


--
[ Artur M. Piwko : Pipen : AMP29-RIPE : RLU:100918 : From == Trap! : SIG:217B ]
[ 22:06:17 user up 10478 days, 10:01, 1 user, load average: 0.06, 0.06, 0.06 ]

Even God cannot change the past.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Clearing the output screen Colin Hemmings Java 3 02-21-2006 12:20 AM
Newbie question - clearing screen @ interactive prompt Kaizer Python 3 12-10-2005 08:40 AM
Clearing Screen Sebastian Becker C++ 2 01-12-2005 09:28 PM
Re: Clearing the screen Nick Coghlan Python 5 12-27-2004 01:32 PM
Clearing IDLE's screen? Miki Tebeka Python 3 02-09-2004 09:13 PM



Advertisments