Skip to main content

AdvancedPrinter

CI PyPI

Small terminal printing helpers for Python: colours, styles, inline text, readable status messages, and Unicode-aware frames. Built on Python's standard streams and one runtime dependency, wcwidth.

Requires Python 3.10+. Upgrading from 1.x? Read the migration guide.

Install

python -m pip install --upgrade AdvancedPrinter
python -m advancedprinter

Print with colours and styles

from advancedprinter import print

print("Repository updated", color="green", style="bold")
print("Downloaded", 3, "packages", sep=" | ")
print("Custom colour", color="#ff8800", background="black")
print("Combined styles", style="bold italic underline")

The original short arguments and class imports still work:

from advancedprinter import AdvancedPrinter as ap

ap.print("Green text", c="green")
ap.print("Bold italic text", s="b-it")
ap.print("White on blue", c="white", b="blue")
ap.help()

print() supports the standard sep, end, file, and flush parameters. Colours may be palette names, #RRGGBB, RGB tuples, or xterm indexes from 0 to 255. Unknown names and conflicting aliases raise descriptive exceptions.

Terminal output and log files

from advancedprinter import Printer

console = Printer(color_mode="auto")
console.success("Repository updated")
console.warning("Using cached release information")
console.info("Downloaded", 3, "packages")
console.error("Download failed")  # stderr by default

with open("sync.log", "w", encoding="utf-8") as log:
    console.print("This file gets plain text", color="green", file=log)

The default auto policy inspects the actual destination stream. Redirected output, pipes, and TERM=dumb get plain text. Non-empty NO_COLOR disables colours in automatic mode while retaining attributes such as bold.

  • color_mode="always" explicitly enables styling, even in files or with NO_COLOR.
  • color_mode="never" removes all ANSI escape sequences, including inline ones.
  • color_system="auto" detects standard, 256-colour, or truecolour support from TERM and COLORTERM. Set the depth explicitly when detection is insufficient.

Printers have independent configuration. No global setup or monkey-patching is required. file=None resolves the current sys.stdout at the time of each call.

Inline formatting and pure rendering

from advancedprinter import format_text, line, print

name = line("Kaloian", color="blue", style="bold")
print(f"Hello, {name}!")

# Outer formatting resumes after the inner span ends.
print("Before " + line("inside", color="blue") + " after", color="red")

plain = format_text("No escape codes", color="green", color_mode="never")

line() is an alias of format_text(). These pure functions return strings and default to ANSI output, independent of the environment. They do not inspect stdout; the printing operation applies the destination's policy. Use color_mode="never" when you need a plain string directly. The pure functions require explicit policies; auto is only available on output operations.

Frames

from advancedprinter import Printer, format_frame

console = Printer()
console.frame(
    "Downloaded 3 packages\n中文 and emoji 👋 are measured in terminal cells",
    title="Repository sync",
    border="rounded",
    border_color="cyan",
    max_width=48,
    padding=1,
)

text = format_frame("Ready", border="double", color_mode="never")
console.print(text)

Borders: basic, basic2, single, double, and rounded. Frames support colours, titles, horizontal padding, alignment, wrapping, and ascii=True. width and max_width include borders and padding. Indentation, trailing spaces, and blank lines are preserved; use dedent=True to remove common indentation. A character or title that cannot fit raises ValueError rather than breaking the frame. frame() prints; format_frame() returns a string.

Input, themes, and logging

from advancedprinter import MessageStyle, Printer

console = Printer(
    theme={
        "success": MessageStyle(color="cyan", style="bold", prefix="DONE"),
    }
)
console.success("All tasks complete")
answer = console.input("  Continue? ", color="yellow")

Input prompts are preserved exactly. input() without a prompt is supported; EOF and keyboard interrupts behave normally.

import logging
import sys
from advancedprinter import ColorFormatter

handler = logging.StreamHandler(sys.stderr)
handler.setFormatter(
    ColorFormatter(
        "%(levelname)s: %(message)s",
        stream=handler.stream,
    )
)
logger = logging.getLogger("sync")
logger.addHandler(handler)
logger.setLevel(logging.INFO)
logger.info("Repository updated")

Use an ordinary logging.Formatter for file handlers. Pass the console handler's actual stream to ColorFormatter; log records are not modified.

Documentation and development

CI tests Python 3.10–3.14 on Linux, Windows, and macOS, checks formatting and static types, and validates the built wheel and source distribution. Publishing a GitHub Release runs the same checks, verifies the tag matches the package version, and uploads the validated distributions through PyPI Trusted Publishing. The one-time publisher setup is described in the release guide.

Terminal rendering still depends on fonts and terminal support. Italic and strike-through are not available everywhere; emoji widths can vary between terminals. Windows automatic mode uses VT support where available and falls back to plain output otherwise. Border characters fall back to ASCII when the stream encoding requires it; non-encodable user content still raises the normal error.

License and support

MIT · Buy me a coffee

Metadata

Release files for AdvancedPrinter 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for AdvancedPrinter 2.0.0
File Size Uploaded Provenance
advancedprinter-2.0.0.tar.gz 31.3 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for AdvancedPrinter 2.0.0
File Interpreter ABI Platform
advancedprinter-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 48.8 kB

Release files / advancedprinter-2.0.0.tar.gz

Download URL advancedprinter-2.0.0.tar.gz
Size 31.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6ffd8c46b00122726ddb420cf9b9b6cd420532389770d2b44603c4dedf6a55e0
BLAKE2b-256 checksum
How to use checksums
18872db15a808459cd4b6b94d8522dc75ab2fd0a8326e3e4c277b31839ce85e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / advancedprinter-2.0.0-py3-none-any.whl

Download URL advancedprinter-2.0.0-py3-none-any.whl
Size 17.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9b9704fc58f56f45d6cad4f9f3e206f47fe9c14b20a8e689d0e2ba3d0b7c8584
BLAKE2b-256 checksum
How to use checksums
5d00e2e729e4af0af1e6abfb09931cedb3ec02e43c8646b28ac52f34feb96578
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Security for AdvancedPrinter 2.0.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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for advancedprinter-2.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page