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.RstResetC.BrBrightC.DiDimC.UnUnderscoreC.BlBlinkC.RvReverseC.BlkBlackC.RedRedC.GrnGreenC.YloYellowC.BluBlueC.MagMagentaC.CyaCyanC.WhiWhiteC.BgBlkBgBlackC.BgRedBgRedC.BgGrnBgGreenC.BgYloBgYellowC.BgBluBgBlueC.BgMagBgMagentaC.BgCyaBgCyanC.BgWhiBgWhite
Logging & Errors
msg(*m)Likeprint()but automatically appendsC.Rstto the end.err(e: Any, ex: int=0)Prints an error to the console (stderr) in red. Ifexis non-zero, also exits with exit code.warn(w: Any)Prints a warning to the console (stderr) in yellow.eInfo(e: Exception)Returns a human-readable string for the exception.onMsg = callable(m: str)If defined, redirects output frommsg()onErr = callable(e: str)If defined, redirects output fromerr()
Main & Exit
execMain(main: callable)Wrapsmainso that when it ends, all atexit functions are run, even if an exception or interrupt occurs.atexit(f: callable)Runfbefore exit. More reliable than builtinatexitmodule ifexecMain()is used, falls back on atexit otherwise.exit(ex: int=0)Overrides builtinexitto exit cleanly, with optional exit code.
Misc
getDictKey(d: dict, val: Any)Returns the first key indwhose value isval. Raises ValueError if not found.
Project details
Release history Release notifications | RSS feed
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.6.tar.gz
(18.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pycolorutils-1.2.6.tar.gz.
File metadata
- Download URL: pycolorutils-1.2.6.tar.gz
- Upload date:
- Size: 18.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ba12a8a2d51ddd7a03a04309a9b238695dd49b5aa7680c36b768075842833d1
|
|
| MD5 |
06ffa5e50d268e40dcd6859045ce3965
|
|
| BLAKE2b-256 |
b1b97806b2eaa563db3a4bec9b5c53998b81da6b804efecd23864e0105428628
|
File details
Details for the file pycolorutils-1.2.6-py3-none-any.whl.
File metadata
- Download URL: pycolorutils-1.2.6-py3-none-any.whl
- Upload date:
- Size: 19.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0508003ab18cb4bf12fe824c0c2bad18d407294250efd2ed10aac853aa715931
|
|
| MD5 |
4e0d9795ed83e14c72dda8bcd36a6d40
|
|
| BLAKE2b-256 |
6f7efabe20f40355ed4fa89ec6d1f1fc9f81f8d51d5a49dc7bc1809df1f0d631
|