Skip to main content

hunterMakesPy

Utilities for converting mixed input to integers, calculating CPU limits, handling None values, importing code dynamically, and manipulating nested data.

pip install hunterMakesPy

Validate, Convert, and Parse Inputs

Convert Mixed Input to Validated Integers

Accepts strings, floats, complex numbers, and UTF-8 binary data and returns a list of validated integers. Ambiguous or incompatible values produce descriptive errors.

from hunterMakesPy.parseParameters import intInnit

ports = intInnit(["8080", 443, "22"], "server_ports")
# Returns: [8080, 443, 22]

Calculate Concurrency Limits from Flexible Specifications

Pass 0.75 for 75% of CPUs, True for 1 CPU, 4 for exactly 4 CPUs, or -2 to reserve 2 CPUs.

from hunterMakesPy.parseParameters import defineConcurrencyLimit

workers = defineConcurrencyLimit(limit=0.75)  # 6 on an 8-core machine

Interpret Strings as Boolean or None

Parse string values such as "true", "false", or "none" into their Python equivalents without raising exceptions on mismatch.

from hunterMakesPy.parseParameters import oopsieKwargsie

oopsieKwargsie("True")   # Returns: True
oopsieKwargsie("none")   # Returns: None
oopsieKwargsie("hello")  # Returns: "hello"

Eliminate None with Runtime Validation

Convert Type | None return annotations to Type by raising at runtime if the value is None. Removes None-checking noise from downstream code and satisfies type checkers.

from hunterMakesPy import raiseIfNone

config = raiseIfNone(getConfig(), "Missing configuration")

Annotate Functions Whose Names You Read

Annotate a function with CallableFunction instead of Callable when your code reads __name__. CallableFunction[[int, int], int] checks a signature the same way that Callable[[int, int], int] does, and type checkers also accept __name__ and __qualname__.

from hunterMakesPy import CallableFunction
from operator import add

direction: CallableFunction[[int, int], int] = add
direction.__name__  # "add"

Replace Ambiguous Numeric Literals with Semantic Names

Use decreasing instead of -1, inclusive for boundary adjustments, and zeroIndexed for index conversions. Intent becomes explicit and the code reads as prose.

from hunterMakesPy import decreasing, inclusive, zeroIndexed

rangeEnd = lengthSequence + inclusive
indexLast = lengthSequence - zeroIndexed
step = decreasing

Color Terminal Text with High-Contrast Pairs

ansiColor holds 21 ANSI escape sequences, and each sequence sets both the text color and the background color, such as ansiColor.YellowOnRed. Write ansiColorReset after the colored text.

from hunterMakesPy import ansiColor, ansiColorReset

print(f"{ansiColor.GreenOnBlack}Success{ansiColorReset}")

Import Modules by Dot-Notation Path or File Path

Load functions or classes from "scipy.signal.windows" or "path/to/file.py" without manual module-loading boilerplate.

from hunterMakesPy.kitFilesystem import importLogicalPath2Identifier, importPathFilename2Identifier

windowFunction = importLogicalPath2Identifier("scipy.signal.windows", "hann")
parse = importPathFilename2Identifier("path/to/asdl.py", "parse")

Create Directories Safely and Write Files with Formatting

Write to "deep/nested/path/file.txt" and parent directories are created automatically. appendStringToHere adds text to the end of a file. writePython removes unused imports and sorts import statements before writing.

from hunterMakesPy.kitFilesystem import appendStringToHere, writePython, writeStringToHere

writeStringToHere("content", "nested/dirs/file.txt")         # Creates dirs
appendStringToHere("more content", "nested/dirs/file.txt")   # Adds to the end
writePython(sourceCode, "output/module.py")                  # Formats, then writes

Extract Strings from Arbitrarily Nested Data

Recursively traverse dictionaries, lists, tuples, sets, and other iterables and collect a string for every key and value into a flat list. Numbers and other values contribute their str representations, and functions contribute their names.

from hunterMakesPy.dataStructures import stringItUp

strings = stringItUp({"users": ["alice"], "config": {"host": "localhost"}})
# Returns: ["users", "alice", "config", "host", "localhost"]

Merge Dictionaries with List Values

Combine {"a": [1, 2]} and {"a": [3], "b": [4]} into {"a": [1, 2, 3], "b": [4]} with optional deduplication and sorting.

from hunterMakesPy.dataStructures import updateExtendPolishDictionaryLists

merged = updateExtendPolishDictionaryLists(
    {"servers": ["chicago"]},
    {"servers": ["tokyo", "chicago"]},
    destroyDuplicates=True,
)
# Returns: {"servers": ["chicago", "tokyo"]}

Compress NumPy Arrays to Self-Decoding Strings

Encode repetitive patterns and consecutive sequences using run-length encoding and Python range syntax. The resulting string evaluates back to the original data.

import numpy
from hunterMakesPy.dataStructures import autoDecodingRLE

encoded = autoDecodingRLE(numpy.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9, 13, 13, 13, 13, 13, 21]))
# Returns: "[*range(10)]+[9]*3+[13]*5+[21]"

Configure Package Metadata at Runtime

PackageSettings resolves the package name, the installation path, and the default file extension automatically. Packaging fixes the name: for an installed package, PackageSettings reads the name that packaging copied from pyproject.toml into the package's metadata, so the pyproject.toml in the current working directory cannot change it. Installation fixes the path. The default file extension is .pyi for a package classified Typing :: Stubs Only and .py otherwise; pass fileExtension to choose another, such as .pyx.

from hunterMakesPy import PackageSettings

settings = PackageSettings(identifierPackageFALLBACK="myPackage")

Report the Call That Broke a Test

Import assertion functions that name the function and the arguments in the failure message, so a failing parameterized test shows exactly which call produced the wrong value. assert_array_equal and assert_allclose do the same for NumPy arrays.

from hunterMakesPy.tests import assertEqualTo

assertEqualTo(intInnit(["8080", 443]), [8080, 443], intInnit.__name__, ["8080", 443])

My recovery

2011 August: Homeless since License: CC BY-NC 4.0

By law, authors retain their copyrights unless they grant exceptions. The Creative Commons Attribution-NonCommercial 4.0 International Deed outlines how you may use this work.

The restriction on commercial use (without a license) limits advantage-taking, unjust enrichment, and exploitation. You would be morally wrong if you were to enrich yourself by using this work while I am denied healthcare, housing, security of property, and the safety of my person.

To obtain and retain the right to use this work, you incur the cost of attributing the work to me. Your nominal cost might accrue as a benefit that mitigates my suffering or saves my life.

Metadata

Release files for hunterMakesPy 0.11.0

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

Source distribution (sdist)

Source distribution for hunterMakesPy 0.11.0
File Size Uploaded Provenance Actions
huntermakespy-0.11.0.tar.gz 64.1 kB Without provenance Details for huntermakespy-0.11.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hunterMakesPy 0.11.0
File Interpreter ABI Platform Actions
huntermakespy-0.11.0-py3-none-any.whl Python 3 none any Details for huntermakespy-0.11.0-py3-none-any.whl

Total release size: 134.2 kB

Release files / huntermakespy-0.11.0.tar.gz

Download URL huntermakespy-0.11.0.tar.gz
Size 64.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ea9a3c9b503ffec7d8b4f7e293e262b6a07bd66b53afb20896a924c132437ad9
BLAKE2b-256 checksum
How to use checksums
fcb79470939f48c6d1faef9823e800a2cd792d691100cd4c90d3bdf3ba7723e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / huntermakespy-0.11.0-py3-none-any.whl

Download URL huntermakespy-0.11.0-py3-none-any.whl
Size 70.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e873c26d9425e2b2cad63feba2859ae7cae78f193044f467f94687502c0c6c5b
BLAKE2b-256 checksum
How to use checksums
753fa7a5e82b0d7c1f6b6cce365fe6fed84c6fe750cb31c719359ca5b603e46e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Security for hunterMakesPy 0.11.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.11.0 This release

2 release files No provenance

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