d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Python, Changing Output Without New Line
Add Reply New Topic New Poll
Member
Posts: 27,007
Joined: Feb 15 2007
Gold: 0.77
Feb 7 2014 09:02am
Hello, using Python is it possible to have a changing output line, without it printing it on a new line, if that makes sense

So for example, I'm printing out three variable from an accelerometer, Roll, Pitch and Yaw, I'd like the 3 variables to be constantly updating, however I don't want a new line printed each time they update

Roll: 44.03 Pitch 0.00 Yaw 78.44

So I'd like the numbers to update themselves with Roll, Pitch and Yaw being printed again on a new line


I hope this make sense, thanks!
Member
Posts: 11,610
Joined: Oct 28 2008
Gold: 1,795.00
Feb 7 2014 10:07am
\r
Member
Posts: 10,812
Joined: Oct 15 2009
Gold: Locked
Warn: 20%
Feb 7 2014 10:17am
Code
def Back_Print(message):
sys.stdout.write("\r"+message)
sys.stdout.flush()


import time
import sys

Back_Print("I")
time.sleep(2)
Back_Print("like")
time.sleep(2)
Back_Print("turtles!")

print "\n"
Member
Posts: 27,007
Joined: Feb 15 2007
Gold: 0.77
Feb 7 2014 10:32am
sweet thanks guys :)
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll