We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,459 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Changing the displayed text while removing it

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?

4
Contributors
8
Replies
9 Hours
Discussion Span
1 Year Ago
Last Updated
9
Views
Question
Answered
inuasha
Light Poster
26 posts since Dec 2011
Reputation Points: 10
Solved Threads: 3
Skill Endorsements: 0

without having the first table appear?

I do not get it.

pyTony
pyMod
Moderator
6,330 posts since Apr 2010
Reputation Points: 879
Solved Threads: 989
Skill Endorsements: 27

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.

inuasha
Light Poster
26 posts since Dec 2011
Reputation Points: 10
Solved Threads: 3
Skill Endorsements: 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()
pyTony
pyMod
Moderator
6,330 posts since Apr 2010
Reputation Points: 879
Solved Threads: 989
Skill Endorsements: 27

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.

nosehat
Newbie Poster
15 posts since Dec 2010
Reputation Points: 10
Solved Threads: 3
Skill Endorsements: 0

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

inuasha
Light Poster
26 posts since Dec 2011
Reputation Points: 10
Solved Threads: 3
Skill Endorsements: 0

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

inuasha
Light Poster
26 posts since Dec 2011
Reputation Points: 10
Solved Threads: 3
Skill Endorsements: 0
Question Answered as of 1 Year Ago by pyTony and nosehat

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.

pyTony
pyMod
Moderator
6,330 posts since Apr 2010
Reputation Points: 879
Solved Threads: 989
Skill Endorsements: 27

To clear the screen in a linux terminal, use this

print("\x1B[2J")
Gribouillis
Posting Maven
Moderator
3,101 posts since Jul 2008
Reputation Points: 1,130
Solved Threads: 761
Skill Endorsements: 11

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0863 seconds using 2.79MB