When you are executing loops (really large ones), you can show a smart progress bar. A library called tqdm creates a progress meter that keeps track of the progress of your loop. To install the library run:
pip install tqdm
Let’s say you have a range(100000) that you want your loop to run through, and after every loop, you want your code to sleep for 0.001 sec. Here is how you can implement it with tqdm so you can see the progress of the loop. When you run this code, you will get the progress meter below as the output.
from tqdm import tqdm
for i in tqdm(range(100000)):
pass
time.sleep(0.001)
Output:
You can also put a description in the function to make the progress meter more intuitive.
i tqdm(range(100000), desc= ):
time.sleep(0.001)
Output:
You can now see that the word "progress" in the progress meter. You can put in whatever description you want. Explore the module some more.