larzprogress
Progress bars & spinners that behave in a pipe. Pure Python, zero deps.
Wrap a loop and get a live progress bar with percentage, counts, rate, and ETA - or a spinner for work of unknown length. The part most home-grown progress code gets wrong: when output is not a terminal (a log file, a CI pipe), larzprogress stays silent instead of spraying carriage returns and bar characters into your logs.
from larzprogress import progress, ProgressBar, Spinner
for item in progress(items, desc="Processing"):
handle(item)
# Processing: 62%|███████████░░░░░| 620/1000 [00:12<00:07, 51.2 it/s]
with Spinner("Connecting"):
connect()
Why
- Pipe-safe by default. Output only animates on a TTY; redirect to a file or
run in CI and it produces nothing (no
\r, no half-drawn bars in your logs) - the same care larzcolor takes. - Everything you want on the bar. Percentage, count, elapsed, ETA, and rate, throttled so it doesn't flicker.
- Manual or automatic.
progress(iterable)wraps a loop;ProgressBargives youupdate()/close()for custom flows;Spinnercovers unknown-length work. - Testable & zero-dep. Injectable clock and stream (this repo's tests assert
exact output), no
tqdm, no dependency.
Install
pip install larzprogress
Usage
from larzprogress import progress, ProgressBar, Spinner
# wrap an iterable
for row in progress(rows, desc="Import"):
save(row)
# manual
bar = ProgressBar(total=len(work), desc="Build")
for w in work:
do(w); bar.update()
bar.close()
# or as a context manager
with ProgressBar(total=100) as bar:
for _ in range(100):
bar.update()
# unknown length
with Spinner("Fetching"):
fetch()
Force behaviour with disable=True/False when you need to.
Tests
python -m unittest discover -s tests -v # 13 tests incl. the silent-in-a-pipe guarantee
The Larz stack
One of 30+ pure-Python, zero-dependency libraries at github.com/larz-scripter.
License
MIT (c) larz-scripter
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file larzprogress-0.1.0.tar.gz.
File metadata
- Download URL: larzprogress-0.1.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7cafa33ff7b16e1fafd93e0ebbd456d9cd09361fa7bcb7396068a5e56ad585de
|
|
| MD5 |
540a20c73606267c23a9bc2749b95683
|
|
| BLAKE2b-256 |
3af30d0a4ea682566e9b5c1dae780a305ccebb009cf5a397e6dd227b480cec52
|
File details
Details for the file larzprogress-0.1.0-py3-none-any.whl.
File metadata
- Download URL: larzprogress-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6979f18995c0a95af12c8e376e4bc6cf39f6a43a136b4eb275923e9df9856971
|
|
| MD5 |
b7ff401ac0f93525cab404cce5b4fa6e
|
|
| BLAKE2b-256 |
01cb9e28351e95c24ac6046c9eb3a5baf266f1f6b248fb5d57b69752653759ac
|