Progress bar for a “for” loop in Python script

Using tqdm:

from tqdm import tqdm

for member in tqdm(members):
    # current contents of your for loop

tqdm() takes members and iterates over it, but each time it yields a new member (between each iteration of the loop), it also updates a progress bar on your command line. That makes this actually quite similar to Matthias’ solution (printing stuff at the end of each loop iteration), but the progressbar update logic is nicely encapsulated inside tqdm.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)