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:
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.
If you liked this post, do not forget to subscribe to my newsletter and see you soon for another Python tips.
You can read the first one here