Skip to content

Instantly share code, notes, and snippets.

View splch's full-sized avatar

Spencer Churchill splch

View GitHub Profile
@splch
splch / progress.py
Last active April 21, 2024 11:34 — forked from spava/progress.py
a simple and useful progress bar in python
import time, sys
def progress(iterable, length=33):
total, start = len(iterable), time.monotonic()
for count, it in enumerate(iterable, 1):
yield it
if count % max(1, total // 10000) == 0 or count == total:
percent = count / total
sys.stdout.write(
f'\r▕{"█" * int(length * percent) + " " * (length - int(length * percent))}▏ '