I like how your parent comment has positive karma for saying that "it's fake; who cares," but I'm downvoted into negative for saying "it's fake; I care" : https://news.ycombinator.com/item?id=18735972
# overwrite the line with blank spaces
# this takes care of the case where len(txt) is fewer than the [ len(txt) when this function was last called ]
sys.stdout.write( "\r" + " "*line_len )
sys.stdout.flush()
# write the txt, trimming to line_len
sys.stdout.write( "\r" + txt.replace("\t", " ")[:line_len] )
sys.stdout.flush()
Example usage: