Skip to main content

A small Python utility library including Clamped and other functions.

Project description

PyUtilx

PyUtilx — a lightweight Python library with useful utilities and extended variable types.
Designed for convenience and less routine in logical operations.

Features

  • Clamped — a numeric type with value limits (min, max) and an optional looping mode (loop=True).
    Supports all major operators (+, -, *, /, %, **) and safely handles boundary overflows.

  • to_base() — converts numbers between numeral systems (up to base 36).
    Example: to_base("ZZ", 36, 10)1295.

  • nearest() / closest() / nrst() — finds the closest value from a list.

  • clamp() — clamps a number between two bounds.

  • reverse() — reverses a string or number (sign preserved).

  • sign() — returns the sign of a number: 1, -1 or 0.

Example

from pyutilx import Clamped, to_base, reverse

x = Clamped(5, 0, 10)
x += 8
print(x)  # 10

y = Clamped(9, 0, 10, loop=True)
y += 3
print(y)  # 1

print(to_base("ZZ", 36, 10))  # 1295
print(reverse(-123))  # -321

Why PyUtilx?

PyUtilx isn’t just a collection of random utilities — it’s an attempt to expand Python with missing data types
and simple yet powerful tools that make your code cleaner and more logical.
Clamped is just the beginning.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyutilix-0.1.3.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyutilix-0.1.3-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

Details for the file pyutilix-0.1.3.tar.gz.

File metadata

  • Download URL: pyutilix-0.1.3.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for pyutilix-0.1.3.tar.gz
Algorithm Hash digest
SHA256 1f446c4bfedc3dde4cb25492c1fb31b909e39bb624d2e8320c139927a2864409
MD5 7218182027947d7c0c6de4a396a5df78
BLAKE2b-256 80aae4824a594a54d83b36b4f8cf34330120f19e3ee1325c777a9dc54d110f89

See more details on using hashes here.

File details

Details for the file pyutilix-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pyutilix-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 2.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for pyutilix-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d4b7f061b5eb68b1c5c8d2621b5486824f883aefab35cf7ea4f71af44d97ca0c
MD5 5dac4b167b949a6b399db48150f10256
BLAKE2b-256 baa180e607e63b478880ad5b3275d5f61bd105be392d35bec6edb8f8ee0f84d2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page