All hail tqdm

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 ?.

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:

Image for postVoil !

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

Image for postVoil! 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 ?.

Others things I wrote that you might like

Things you should know about JS events

If you had the chance to do some client-side JS you certainly had to handle events. While libraries such as Jquery have?

www.daolf.com

Python tips 1: beware of Python dict.get()

Beware of Python dict.get() If you think that value = my_dict.get(‘my_key’, ‘default_value’) is equivalent to value =?

www.daolf.com

Git series 1/3: Understanding git for real by exploring the .git directory

“Whoah, I’ve just read this quick tuto about git and oh my god it is cool. I feel now super comfortable using it, and?

www.daolf.com

13

No Responses

Write a response