1.11M Members

Changing the displayed text while removing it

 
0
 

Alright so I was not sure exactly how to say this, but here is the idea. I have a graph or table I guess you could call that looks like this.

print '''
-----------------------------
|
|
|
|x
|
|
|
|-----------------------------
'''

Then I want to make a change to where x is for example moving it down twice.
How would I go about this without having the first table appear?

 
0
 

without having the first table appear?

I do not get it.

 
0
 

I do not get it.

Okay so a simpler example. you do print "hi" then when the script is ran the terminal output hi how do I print hi then like 5 seconds later print "Hello" without the first print statement's output being shown in the terminal.

 
0
 

Something like this:

from __future__ import print_function
import sys
import time

print('Hi!', end='')
time.sleep(5)
print(3*'\b'+'Hello!')
sys.stdout.flush()
 
0
 

Depending on your operating system, there are a couple of ways.

Start with

import os

in your script.

If you are on Linux (also Mac I think) you can do:

os.system("clear")

to clear the terminal screen.

If you are on Windows you can do:

os.system("cls")

Note that these probably won't work on IDLE or similar, but will work from the terminal. Clear the screen, and redraw your chart.

 
0
 

Thanks very much pyTony that is not something I even knew existed. Where did you learn python from?

 
0
 

Thanks to you as well nosehat you commented as I posted my last one. Where did you learn this?

Question Answered as of 2 Years Ago by pyTony and nosehat
 
0
 

Thanks very much pyTony that is not something I even knew existed. Where did you learn python from?

I learned it basically from online tutorials, but real learning happens when you "play with the language". I do know several languages before starting with TI-58C programmable calculator, where the language is basically key codes as numbers and floating point values, basically assembly level language, 1981 as school boy of 8th grade.

 
0
 

To clear the screen in a linux terminal, use this

print("\x1B[2J")
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: