A python library to display progress of loops to the user
Reason this release was yanked:
Example code does not work
Project description
ProgressBars
A python library to display progress of loops to the user.
Installation
This library can be installed using pip.
pip install progressbars
Usage
The class you'll be using is called the ProgressBar class, here is an example of how to use it.
from progressbars import ProgressBar, widgets
def isPrime(n: int) -> bool:
"A very slow algorithm to calculate if a given number is prime."
for i in range(2, n):
if n % i == 0:
return False
return n > 1
# Create an empty list to store the primes we find
primes = []
# Create a red progress bar, update it every 10 iterations and use the percentage, iteration speed, counter, elapsed time and remaining time widgets
bar = ProgressBar([
widgets.Percentage,
widgets.IterationSpeed,
widgets.Counter,
widgets.ElapsedTime,
widgets.RemainingTime
], 10, "red")
# Loop through all numbers from 0-30_000
for i in bar(range(30_000)):
if isPrime(i): # If the current number is prime, append it to the primes list
primes.append(i)
# Print how many primes we found
print("\nFound", len(primes), "primes!")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
progressbars-1.1.3.tar.gz
(3.8 kB
view hashes)
Built Distribution
Close
Hashes for progressbars-1.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18ac2b4eb5d707cd1144c3578eb175ac48e130265d2e94714dfa3c2a1b682359 |
|
MD5 | 3e213fc52bb82aa41723f65a0736d1c1 |
|
BLAKE2b-256 | 794356c3013e3c4b330d6be76ab3b17d3c689330262a86fa8f144f81893e49a8 |