Skip to main content

About

PyPI Version Build

andrewtools is an assortment of handy Python tools made by someone named Andrew.

Quick Start

Supported Python Versions

Python 3.8+

Mac / Linux

pip install andrewtools

Windows

py -m pip install andrewtools

Examples

Progress Bar

If you are working on a program that uses a loop that takes a significant amount of time to execute, it can be nice to follow the progress of your program while it runs. Use progress_bar to visualize the progress via the command line.

import time
from andrewtools import progress_bar

iterations = 10
for i in range(iterations):
    time.sleep(0.5)
    progress_bar(i, iterations, width=10, prefix="Progress")

# Printed to command line:
Progress | ***------- | 30%  <- % and progress bar update in-place while loop runs
  • Warning: this function will not play well if the loop includes other print statements. The progress bar may get printed on a separate line for each iteration, which may not be desirable.
  • Note: in the case of a constant runtime per iteration, the progress bar provides a good estimate of the relative amount of execution time remaining. Be aware that in the case of variable runtimes per iteration (e.g. if there is an inner loop with a varying workload), the progress bar is not a good estimate of the remaining execution time. It simply tracks the progress through the number of iterations.

AndrewTimer

AndrewTimer provides a simple API for a timer to use to measure execution time of your programs.

from andrewtools import AndrewTimer

    at = AndrewTimer()
    for i in range(10):
        time.sleep(0.5)
        at.lap()

        # Use in tandem with `progress_bar` as follows:
        end = f"(Last {at.last_lap(format=True)}) (Total: {at.elapsed(format=True)})"
        progress_bar(i, 10, width=10, label="Progress", end=end)

    # Measure total time since instantiation
    total_time = at.elapsed('s', format=True)

    # Measure average time of all laps recorded on the timer
    average_time = at.average('s', format=True)

    # Display formatted times
    print(f"Total: {total_time}, Average: {average_time}")  # approx. 5.000s 0.500s

Release files for andrewtools 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for andrewtools 0.1.1
File Size Uploaded
andrewtools-0.1.1.tar.gz 7.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for andrewtools 0.1.1
File Interpreter ABI Platform
andrewtools-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 14.0 kB

Release files / andrewtools-0.1.1.tar.gz

Download URL andrewtools-0.1.1.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c8801314e059e207c43663d0de116233fbc62144c2b6906117ceb828a3b62686
BLAKE2b-256 checksum
How to use checksums
c9360f6d4f3d485052da208fcb08089441259520fd3585eb43567a57720318ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.14

Release files / andrewtools-0.1.1-py3-none-any.whl

Download URL andrewtools-0.1.1-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d539af8192397d93c41ad36396e920e17fbc9e9a4f2788d587f649e9814290d8
BLAKE2b-256 checksum
How to use checksums
58b5704b9d5e6c57890dabeef024c6ec833bd8b5349bbbbc7a7c665101110995
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.14

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page