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.1.tar.gz (2.5 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.1-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyutilix-0.1.1.tar.gz
  • Upload date:
  • Size: 2.5 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.1.tar.gz
Algorithm Hash digest
SHA256 76e614ac15a9e84aa955b8e7ab7350b5ffe1734b82527b77d7286c99b23edfa2
MD5 ab73ebce65b7caa98df43486ccb76a30
BLAKE2b-256 b7faeee8710434df2c923209f8890b1599a7c274e7800de6c1ea9e2d6fb71d30

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyutilix-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 2.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e2e2dbf0e6b52cf22d6e6a455119693419dc612c54df7f51559092d50f78e09f
MD5 fa3392e3d57b0d90d3601a47ef9803d8
BLAKE2b-256 84564c5a33a761bca62726f93f0f6a84aef513012af258b0734c3bfa1afb34cf

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