Or the end of print(i)
inside a for loop.
If you have ever wrote something like this:
for i in range(0,10000):
compute(i)
print(i)
to control the progress of your execution, this short article is for you đ.
All hail tqdm
tqdm, from the Arabic âtaqadumâ which means âprogressâ is one of the many Python libs that are as useful as they are easy to use. Install it the usual way with pip install tqdm and then:
And you can even make it work with loops inside loops:
Thatâs it.
I hope this lib will help you and that you learn something today. The whole doc is available here.
tqdm
comes with many options that can help you make the progress bar exactly as you want. tqdm also works very well in Jupyter notebook, just do from tqdm import tqdm_notebook
instead of from tqdm import tqdm
.
Thank you for reading
I hope this short post will help you log loops better and impress your colleagues.
Please tell me in the comments if you liked the post and don't forget to subscribe to my newsletter, there is more to come (And you'll also get the first chapters of my next ebook for free đ).
If you like JS, I've just published something you might like.
And if you prefer git, I got you covered.
Top comments (5)
tqdm
is a good recommendation. A different example from a project I worked on recently, usingtqdm
to measure continuous progress (without concrete end) and real-time rate per second, hope it helps:^ will show log entries, with a final line (example w/ 15400 updates completed in 1h30min):
Bonus points if you use
termcolor
as well, e.g.:Very nice snippets, I'm copying those in my note block.
Thank you !!
I didn't know you could do this on Python, excellent post!
Thank you, hope you'll use it ;)