To implement a status bar like below:
[========== ] 45%
[================ ] 60%
[==========================] 100%
I want to this to be printed out to stdout, and keep refreshing it, not print to another line. How to do this?
There’s a Python module that you can get from PyPI called
progressbarthat implements such functionality. If you don’t mind adding a dependency, it’s a good solution. Otherwise, go with one of the other answers.A simple example of how to use it:
To install it, you can use
easy_install progressbar, orpip install progressbarif you prefer pip.