I’m wondering how I could create one of those nifty console counters in Python as in certain C/C++-programs.
I’ve got a loop doing things and the current output is along the lines of:
Doing thing 0
Doing thing 1
Doing thing 2
...
what would be neater would be to just have the last line update;
X things done.
I’ve seen this in a number of console programs and am wondering if/how I’d do this in Python.
An easy solution is just writing
"\r"before the string and not adding a newline; if the string never gets shorter this is sufficient…Slightly more sophisticated is a progress bar… this is something I am using:
You call
start_progresspassing the description of the operation, thenprogress(x)wherexis the percentage and finallyend_progress()