printcolorpt
printcolorpt is a handy ANSI styling helper for Python.
It gives you short, memorable functions for colored terminal output:
from pt import *
printR("error")
printG("success")
printY("warning")
printB("info")
printO("orange")
printC("cyan")
printD("debug")
Version 0.2.0 expands the public API from 10 helpers to 17 helpers:
- 7 full-line print helpers
- 7 inline color wrappers
- 3 raw text-style constants (NEW)
Installation
pip install printcolorpt
Quick start
from pt import *
printR("failed", bold=True)
printG("completed", underline=True)
printY("check this value", italic=True)
printD("debug log", bold=True, italic=True)
The print* helpers behave like Python's built-in print() for common arguments such as sep, end, file, and flush.
from pt import *
printB("x", "y", "z", sep=" -> ")
printC("loading", end="... ", flush=True)
printG("done")
Full-line color printing
Use these when the entire output line should have one color.
from pt import *
printR("red")
printG("green")
printY("yellow")
printB("blue")
printO("orange")
printC("cyan")
printD("dark gray debug")
Each print helper supports the same three style flags:
from pt import *
printR("bold red", bold=True)
printG("italic green", italic=True)
printB("underlined blue", underline=True)
printO("bold italic underlined orange", bold=True, italic=True, underline=True)
Inline color composition
Use uppercase color wrappers when one line needs multiple colors.
from pt import *
print(
RED("ERROR")
+ " | "
+ YELLOW("retrying")
+ " | "
+ GREEN("recovered")
)
A practical status line:
from pt import *
filename = "records.parquet"
rows = 1_240_000
seconds = 3.82
print(
BLUE("READ")
+ " "
+ filename
+ " | "
+ GREEN(f"{rows:,} rows")
+ " | "
+ DEBUG(f"{seconds:.2f}s")
)
A clean validation summary:
from pt import *
passed = 132
failed = 1
skipped = 4
print(
BOLD + "TEST "
+ GREEN(f"PASS={passed}")
+ " "
+ RED(f"FAIL={failed}")
+ " "
+ YELLOW(f"SKIP={skipped}")
)
Text styles
BOLD, ITALIC, and UNDERLINE are raw ANSI style constants.
from pt import *
print(BOLD + RED("bold red"))
print(ITALIC + BLUE("italic blue"))
print(UNDERLINE + CYAN("underlined cyan"))
When composing several styled segments, remember that every color wrapper resets the style at the end of its own text. Re-apply a style before the next segment when needed.
from pt import *
print(
ITALIC + RED("italic red")
+ " "
+ ITALIC + UNDERLINE + BLUE("italic underlined blue")
)
Debugging recipes
Compact debug markers
from pt import *
printD("[1/4] load input")
printB("[2/4] normalize columns")
printY("[3/4] validate missing values")
printG("[4/4] export completed")
Loop progress
from pt import *
items = ["address", "geometry", "date", "score"]
for i, name in enumerate(items, start=1):
printB(f"[{i}/{len(items)}] processing {name}")
# do something here
printG("all steps completed", bold=True)
Exception-friendly output
from pt import *
try:
value = int("not-a-number")
except ValueError as e:
printR("ValueError:", e, bold=True)
printD("hint: check the input type before conversion")
Data pipeline style
from pt import *
print(BOLD + BLUE("PIPELINE START"))
printD("reading source file")
printY("missing values detected in 2 columns")
printG("geometry validation passed")
print(BOLD + GREEN("PIPELINE DONE"))
Public API
Print helpers
| Function | Color | Typical use |
|---|---|---|
printR(...) |
red | errors, failures |
printG(...) |
green | success, completion |
printY(...) |
yellow | warnings, checkpoints |
printB(...) |
blue | information, steps |
printO(...) |
orange | highlights, attention |
printC(...) |
cyan | secondary information |
printD(...) |
dark gray | debug messages |
Inline color wrappers
| Function | Color |
|---|---|
RED(text) |
red |
GREEN(text) |
green |
YELLOW(text) |
yellow |
BLUE(text) |
blue |
ORANGE(text) |
orange |
CYAN(text) |
cyan |
DEBUG(text) |
dark gray |
Style constants
| Constant | Meaning |
|---|---|
BOLD |
bold text |
ITALIC |
italic text |
UNDERLINE |
underlined text |
0.2.0 highlights
- Added
printO()andORANGE(). - Added
printC()andCYAN(). - Added
BOLD,ITALIC, andUNDERLINE. - Added style flags to print helpers:
bold,italic,underline. - Keeps the original simple import style:
from pt import *. - Still no external dependencies.
Notes
This package uses ANSI escape sequences. Color rendering depends on the terminal or notebook frontend. It works best in modern terminals, VS Code terminals, and Jupyter environments that support ANSI colors.
Metadata
Release files for printcolorpt 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| printcolorpt-0.2.0.tar.gz | 5.1 kB | Without provenance | Details for printcolorpt-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| printcolorpt-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for printcolorpt-0.2.0-py3-none-any.whl |
Total release size: 9.9 kB
Release files / printcolorpt-0.2.0.tar.gz
| Download URL | printcolorpt-0.2.0.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a8df4315e27fe38884b54cdc224f0c1983e10ffb5388e94181f0f624e30d3ea1
|
|
BLAKE2b-256 checksum How to use checksums |
7305bf571b57d00182c4650cffec62d52173785d1cc00944f21b1aa6c893879e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / printcolorpt-0.2.0-py3-none-any.whl
| Download URL | printcolorpt-0.2.0-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a4d340b6f136cdf436939d1b5e283e363f4304605ccf506211363f4955130d03
|
|
BLAKE2b-256 checksum How to use checksums |
08129634d8f4fbb6aa9ddf7490240a439c695c1eea1c96f9db63091593cb02b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Security for printcolorpt 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.