Hey guys/gals I'm writing a python script that fixes some duplicate issues on my database. I would like to display some progress status to the users, currently I just print it like this:
print "Merged " + str(idx) + " out of " + str(totalCount);
The problem is that it prints that in a new line for every record and that does not look so good :) I'd like to either always print the string above on the same line on the screen or use some smart widget that displays it in some sort of progress bar.
I intent to run this on the command line, any suggestions will be much appreciated.
2 Answers 2
If you just want to constantly overwrite the same line, use '\r' and print foo, to act as a carriage return and a non-endline-printing print.
while doingStuff:
msg = "\rMerged %s out of %s" % (idx, totalCount)
print msg,
But if you're designing a fancier console app, you maybe should look into using curses (only for Unix though)
Comments
Check out fish.