Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- textlen = 0 #used to clear lines this is required or with input of "hello" and "test" it will show "testo"
- def writeline(text):
- global textlen
- if text== "" or not isinstance(text, basestring):
- raise "Requred string is not set" ##basic error handeling (this may be incorrect, im using classes where i got this code from
- sys.stdout.write('\r' + ' ' * textlen + '\r') ##pints spaces equle to the amount of characters from the last message and overwrights the last message
- sys.stdout.flush()
- sys.stdout.write('\r' + str(text) + '\r') ##overwrights those spaces with new characters
- sys.stdout.flush()
- textlen = len(text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement