How do I use a progress bar when my script is doing some task that is likely to take time?
For example, a function which takes some time to complete and returns
You can use tqdm:
from tqdm import tqdm
with tqdm(total=100, desc="Adding Users", bar_format="{l_bar}{bar} [ time left: {remaining} ]") as pbar:
for i in range(100):
time.sleep(3)
pbar.update(1)
In this example the progress bar is running for 5 minutes and it is shown like that:
Adding Users: 3%|█████▊ [ time left: 04:51 ]
You can change it and customize it as you like.