The tqdm package in Python provides a fast, extensible progress bar for loops and other iterable objects. It was used in pip intall. Here’s a simple example:
from tqdm import tqdm import time
# Create a list of numbers numbers = range(100)
# Wrap your iterable with tqdm() for i in tqdm(numbers): # Simulate some work time.sleep(0.01)
rich
from rich.progress import track import time
# Create a list of numbers numbers = range(100)
# Wrap your iterable with track() for i in track(numbers, description="Processing..."): # Simulate some work time.sleep(0.01)
track() works similarly to tqdm’s wrapper. It takes an iterable and a description for the task, and returns an iterator that produces the same values as the original, but also updates a progress bar in the console as it iterates over the items.
The description parameter allows you to set a text description for the task that is displayed next to the progress bar.
Like tqdm, rich offers a variety of options to customize the appearance and behavior of the progress bar. You can find more details in the rich documentation.
bar = progressbar.ProgressBar(max_value=20, widgets=widgets).start()
for i inrange(20): time.sleep(0.1) bar.update(i) from rich.progress import track import time
# Create a list of numbers numbers = range(100)
# Wrap your iterable with track() for i in track(numbers, description="Processing..."): # Simulate some work time.sleep(0.01) from tqdm import tqdm import time
# Create a list of numbers numbers = range(100)
# Wrap your iterable with tqdm() for i in tqdm(numbers): # Simulate some work time.sleep(0.01)