Clearing the screen of text

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Sep 2009
Posts: 112
Reputation: AutoPython is an unknown quantity at this point 
Solved Threads: 9
AutoPython's Avatar
AutoPython AutoPython is offline Offline
Junior Poster

Clearing the screen of text

 
0
  #1
Sep 6th, 2009
I can't find a simple command that does this. If there's no command that does this I'm going to spam python.org until they finally agree to put this in the next version of python.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 1,614
Reputation: scru has a spectacular aura about scru has a spectacular aura about 
Solved Threads: 131
Featured Poster
scru's Avatar
scru scru is offline Offline
Posting Virtuoso

Re: Clearing the screen of text

 
-1
  #2
Sep 6th, 2009
Python.org supposedly loves spam anyway, so long as you include some eggs.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 112
Reputation: AutoPython is an unknown quantity at this point 
Solved Threads: 9
AutoPython's Avatar
AutoPython AutoPython is offline Offline
Junior Poster

Re: Clearing the screen of text

 
0
  #3
Sep 6th, 2009
I was hoping for a more insightful answer
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 1,614
Reputation: scru has a spectacular aura about scru has a spectacular aura about 
Solved Threads: 131
Featured Poster
scru's Avatar
scru scru is offline Offline
Posting Virtuoso

Re: Clearing the screen of text

 
0
  #4
Sep 6th, 2009
Sigh.

No, python doesn't have clear screen.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 112
Reputation: AutoPython is an unknown quantity at this point 
Solved Threads: 9
AutoPython's Avatar
AutoPython AutoPython is offline Offline
Junior Poster

Re: Clearing the screen of text

 
0
  #5
Sep 6th, 2009
there's not even some way to trick the computer into clearing the screen of text?
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 984
Reputation: Gribouillis is a jewel in the rough Gribouillis is a jewel in the rough Gribouillis is a jewel in the rough 
Solved Threads: 222
Gribouillis's Avatar
Gribouillis Gribouillis is offline Offline
Posting Shark

Re: Clearing the screen of text

 
0
  #6
Sep 6th, 2009
I suggest
  1. >>> print("\n" * 40)
Or even better
  1. >>> def clear():
  2. ... print("\n"*40)
  3. >>> clear()
Last one:
  1. >>> def clear():
  2. ... import sys
  3. ... for i in range(40):
  4. ... print(sys.ps1)
Last edited by Gribouillis; Sep 6th, 2009 at 4:29 pm.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 112
Reputation: AutoPython is an unknown quantity at this point 
Solved Threads: 9
AutoPython's Avatar
AutoPython AutoPython is offline Offline
Junior Poster

Re: Clearing the screen of text

 
0
  #7
Sep 6th, 2009
The last one doesn't work, says the attribute ps1 doesn't exist. But that is what I was planning to do at first, but then that leaves a big side bar. Oh well, I guess I'll just have to use the print thing.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,141
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 947
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: Clearing the screen of text

 
3
  #8
Sep 6th, 2009
Clearing the display screen in console mode depends on the Operating System, that and the limited usefulness is why many multiplatform computer languages do not include it.

Here is a Python version using module os ...
  1. import os
  2. # works on windows nt (also xp and vista) or linux
  3. os.system(['clear','cls'][os.name == 'nt'])
Last edited by vegaseat; Sep 6th, 2009 at 6:14 pm.
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 112
Reputation: AutoPython is an unknown quantity at this point 
Solved Threads: 9
AutoPython's Avatar
AutoPython AutoPython is offline Offline
Junior Poster

Re: Clearing the screen of text

 
0
  #9
Sep 6th, 2009
That works perfect! Now the problem is really solved.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 16
Reputation: Warkthogus is an unknown quantity at this point 
Solved Threads: 0
Warkthogus Warkthogus is offline Offline
Newbie Poster
 
0
  #10
Oct 20th, 2009
  1. import os
  2. # works on windows nt (also xp and vista) or linux
  3. os.system(['<strong class="highlight">clear</strong>','cls'][os.name == 'nt'])
Can anyone kindly explain the background of how this bit of code works?
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the Python Forum


Views: 722 | Replies: 12
Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC