stouputils.print.progress_bar module#

colored_for_loop(
iterable: Iterable,
desc: str = 'Processing',
color: str = '\x1b[95m',
bar_format: str = '{l_bar}{bar}\x1b[95m| {n_fmt}/{total_fmt} [{rate_fmt}{postfix}, {elapsed}<{remaining}]\x1b[0m',
ascii: bool = False,
smooth_tqdm: bool = True,
**kwargs: Any,
) Iterator[source]#

Function to iterate over a list with a colored TQDM progress bar like the other functions in this module.

Parameters:
  • iterable (Iterable) – List to iterate over

  • desc (str) – Description of the function execution displayed in the progress bar

  • color (str) – Color of the progress bar (Defaults to ::attr::MAGENTA)

  • bar_format (str) – Format of the progress bar (Defaults to ::attr::BAR_FORMAT)

  • ascii (bool) – Whether to use ASCII or Unicode characters for the progress bar (Defaults to False)

  • smooth_tqdm (bool) – Whether to enable smooth progress bar updates by setting miniters=1 and mininterval=0.0 (Defaults to True)

  • **kwargs – Additional arguments to pass to the TQDM progress bar

Yields:

T – Each item of the iterable

Examples

>>> import time
>>> for i in colored_for_loop(range(10), desc="Time sleeping loop"):
...     time.sleep(0.01)
>>> # Time sleeping loop: 100%|██████████████████| 10/10 [ 95.72it/s, 00:00<00:00]