Posts Tagged ‘tqdm’

a command line progress bar for your loops

January 10, 2014 Leave a comment

When I was working on Project Euler, there were several problems that I solved with a brute force approach and thus the runtime was several hours. To see some changes and to know approximately when it finishes, I added a simple counter to the main loop that showed the progress in percentage.

Is there a simpler way to add a progress bar to a loop?

The project tqdm addresses this problem. Reddit discussion is here.

Usage example:

import time
from tqdm import tqdm

def main():
    for i in tqdm(range(10000)):


  • you can use xrange too: tqdm(xrange(10000))
  • you can write trange: trange(10000)

On the github page of the project you will find an animated gif too.

Categories: python Tags: , , ,