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.

2 Answers 2

4

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)

Sign up to request clarification or add additional context in comments.

Comments

4

Check out fish.

2 Comments

+1 for "The default fish is a simple bass at a pretty good velocity for an ASCII fish."
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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.