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?

Recommended Answers

All 8 Replies

without having the first table appear?

I do not get it.

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.

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()

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.

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

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

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.

To clear the screen in a linux terminal, use this

print("\x1B[2J")
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.