Logging loop progress in Python like a pro with tqdm

Pierre de Wulf
2 min readJan 16, 2019

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:

Voilà !

And you can even make it work with loops inside loops:

Voilà! Voilà!

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:

If you like the article, the first tip is available here.

Don’t forget to subscribe if you want to receive my new posts directly into your inbox. I am soon starting something new and exciting 😎.

I write about tech in general and recently, more about how I built my new price competitor monitoring business.

See you next week for another Python tip 😃.

--

--