Day 58: Using Progress Bars In The Shell (Module)

 

The module ProgressBar generates timed progress bars in the terminal while you execute a program.

 

A progress bar is seldomly really necessary but sometimes it is just neat to display some progress for the user

 

You can find the documentation here

 

An easy example:

 

from time import sleep                          # to use the timer
from progressbar import ProgressBar             # progressbar module


print("Multiplying 987.000 * 1.210.100")        

num = 987000 * 1210100


bar = ProgressBar()                         
for i in bar(range(100)):
    sleep(0.01)
    bar.update(i)

print("Result: " + str(num))

And this is what it looks like in the terminal: