Skip to main content

A set of useful utilities for Python

Project description

PyColorUtils

A set of useful utilities for Python. Same vibe as C-Utils and Utils.js.

Install via pip install pycolorutils

Color Preset Strings

Format strings for console printing.

  • C.Rst Reset
  • C.Br Bright
  • C.Di Dim
  • C.Un Underscore
  • C.Bl Blink
  • C.Rv Reverse
  • C.Blk Black
  • C.Red Red
  • C.Grn Green
  • C.Ylo Yellow
  • C.Blu Blue
  • C.Mag Magenta
  • C.Cya Cyan
  • C.Whi White
  • C.BgBlk BgBlack
  • C.BgRed BgRed
  • C.BgGrn BgGreen
  • C.BgYlo BgYellow
  • C.BgBlu BgBlue
  • C.BgMag BgMagenta
  • C.BgCya BgCyan
  • C.BgWhi BgWhite

Logging & Errors

  • msg(*m) Like print() but automatically appends C.Rst to the end.
  • err(e: Any, ex: int=0) Prints an error to the console in red. If ex is non-zero, also exits with exit code.
  • eInfo(e: Exception) Returns a human-readable string for the exception.
  • onMsg = callable(m: str) If defined, redirects output from msg()
  • onErr = callable(e: str) If defined, redirects output from err()

Main & Exit

  • execMain(main: callable) Wraps main so that when it ends, all atexit functions are run, even if an exception or interrupt occurs.
  • atexit(f: callable) Run f before exit. More reliable than builtin atexit module if execMain() is used, falls back on atexit otherwise.
  • exit(ex: int=0) Overrides builtin exit to exit cleanly, with optional exit code.

Misc

  • getDictKey(d: dict, val: Any) Returns the first key in d whose value is val. Raises ValueError if not found.

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

pycolorutils-1.2.2.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

pycolorutils-1.2.2-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file pycolorutils-1.2.2.tar.gz.

File metadata

  • Download URL: pycolorutils-1.2.2.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for pycolorutils-1.2.2.tar.gz
Algorithm Hash digest
SHA256 493f3bdf444ff5d1680d81a0c8afd859703c126da5c7df2c2e0375dab7acc3e6
MD5 bdfe292a09bcffa6550df99c1a81f30c
BLAKE2b-256 d7e11488a8842cee9f8c4338938afabda7254bd8a817e618ea200e9040abbda9

See more details on using hashes here.

File details

Details for the file pycolorutils-1.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pycolorutils-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 26109a321b2948e3ed785253431abb1c9efada64eb6b5f6c371c860176727227
MD5 8e44852dc47a5a71db4119c63e5da9dd
BLAKE2b-256 5de5bd409c5c18714e2eeba53c830b273a71ec08d25aa6d3396541f00a5e9bd9

See more details on using hashes here.

Supported by

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