The module tqdm lets you create a progress bar. This lets you make nice progress bars:
Why the name tqdm?
The developer thought it's a good name. It is an abbreviation for "I love you so much" in Spanish (te quiero demasiado).
Por favor?
Salright.
Create progress meter
Instantly make your loops show a smart progress meter - just wrap any iterable with tqdm(iterable), and you're done!
from tqdm import tqdm
for i in tqdm(range(10000)):
...
Creates
76%|████████████████████████████ | 7568/10000 [00:33<00:10, 229.00it/s]
Demo
The code below creates several threads.
You see, it can be used both on the current thread and with several threads.
#!/usr/bin/python3
import time
import tqdm
def work1():
time.sleep(1)
def work2():
time.sleep(1)
def work3():
time.sleep(1)
def work4():
time.sleep(1)
def work5():
time.sleep(1)
def work6():
time.sleep(1)
def worker():
work_set = [work1, work2, work3, work4, work5, work6]
return work_set
def main():
a = worker()
for i in tqdm.tqdm(range(6)):
b = a[i]()
if __name__ == '__main__':
main()
Then:
100%|████████████████████████████████████| 6/6 [00:06<00:00, 1.00s/it]
Resources:
Top comments (0)