views:

79

answers:

2

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.

+4  A: 

Check out fish.

Hank Gay
+1 for "The default fish is a simple bass at a pretty good velocity for an ASCII fish."
Adam Bernier
Thx, fish looks pretty kewl. I'm marking @Daniel DiPaolo question as the answer because that is what I will use since I don't wanna add the fish dependency to my little script. But Thx very much for the help!
hdx
+4  A: 

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)

Daniel DiPaolo