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.msg(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.3.tar.gz
(6.0 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.3.tar.gz.
File metadata
- Download URL: pycolorutils-1.2.3.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3009512b31acacd32883506b32d322ac6f838d8fedf190aa56c3546c0beb301
|
|
| MD5 |
15eafc72e9198dc9de964ccb26020a59
|
|
| BLAKE2b-256 |
183d0aacc3976a509b6371c19e459a20e7202f2721b2a902221c371571d2ec0d
|
File details
Details for the file pycolorutils-1.2.3-py3-none-any.whl.
File metadata
- Download URL: pycolorutils-1.2.3-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdd5bddb4b676fedeb173ac0792a706de912fc54b9efec53707cbf9c79777a04
|
|
| MD5 |
6b0f93d66fc627d1427ec93c4eba006f
|
|
| BLAKE2b-256 |
b9c0e7e8ed758d4c67c7c4d3e3269743ea88f79851d0b7dccdfbb8b921dd062e
|