A python package to display progress of loops to the user
Project description
ProgressBars
A python package to display progress of loops to the user.
Installation
This package 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 colorless progress bar that uses all the default widgets
bar = ProgressBar([
widgets.Percentage,
widgets.IterationSpeed,
widgets.Counter,
widgets.ElapsedTime,
widgets.RemainingTime
], color=None)
# 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.10.tar.gz
(3.8 kB
view details)
Built Distribution
File details
Details for the file progressbars-1.1.10.tar.gz
.
File metadata
- Download URL: progressbars-1.1.10.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3290e881f35e0c6972e9f5dd725aa78e740ffa62328035c9cb4fe164c665274 |
|
MD5 | 850c1885a36077f64ea6cf62e443e258 |
|
BLAKE2b-256 | 76848d90932c9266eb9723cab707e51ccb2a120c1023ad4c6f3583bd36ea060f |
File details
Details for the file progressbars-1.1.10-py3-none-any.whl
.
File metadata
- Download URL: progressbars-1.1.10-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 494625e243213fc4d7487e5b003833d78ae04cadf1067bdec074bc9dfc5643ca |
|
MD5 | 5e8a5bad8b09d8b929beddd68db17b03 |
|
BLAKE2b-256 | 50b0a1e081da74afa7be4c7d385d03ba53a2d543c0cb36d5a96967507e881c0f |