Progress bar for a "for" loop in Python script

To show the progress bar:

from tqdm import tqdm

for x in tqdm(my_list):
    # do something with x

#### In case using with enumerate:
for i, x in enumerate( tqdm(my_list) ):
    # do something with i and x

enter image description here

Some notes on the attached picture:

49%: It already finished 49% of the whole process

979/2000: Working on the 979th element/iteration, out of 2000 elements/iterations

01:50: It's been running for 1 minute and 50 seconds

01:55: Estimated time left to run

8.81 it/s: On average, it processes 8.81 elements per second


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.