Skip to main content

sgroove

sgroove is a Python library for styling terminal output using ANSI escape sequences. It provides a fluent interface and integrates with Python's f-string formatting.

This started as a small personal project to explore the __format__-Dunder-method but might be useful for someone else, too.

Features

sgroove provides a fluent interface that lets you build up formatting step by step by chaining style calls, which keeps even more complex combinations readable and easy to reuse. It also integrates with Python’s f-string formatting so you can apply styles inline via semicolon-separated format specifiers, making it convenient to style output without wrapping everything in separate function calls.

Supported Colors

For colors, it supports the full range of common terminal options: the 8 standard ANSI colors with bright variants for quick, named styling, the 256-color ANSI palette for finer-grained choices, and 24-bit TrueColor (RGB) for exact color control when your terminal supports it.

Name Bright Variant
black bright_black
red bright_red
green bright_green
yellow bright_yellow
blue bright_blue
magenta bright_magenta
cyan bright_cyan
white bright_white

Supported Styles

In addition to colors, it includes widely used text modifiers—such as bold, italic, and underline—so you can highlight headings, warnings, and status messages consistently in CLI output.

Specifier Description
bold Bold or increased intensity
faint Decreased intensity
italic Italic font
underlined Underlined text
blinking Blinking text
crossed_out Strikethrough
framed Framed text
encircled Encircled text
overlined Overlined text

Examples

Fluent Interface

The fluent interface allows you to build styles by chaining method calls on an AnsiStr object.

from sgroove import S

# Simple red text
print(S("Hello").fg("red"))

# Bold and green background
print(S("Success").bold().bg("green"))

# Using RGB colors
print(S("TrueColor").rgb(255, 165, 0)) # Orange

Format Version

sgroove objects can be styled directly within f-strings using the format specifier. Multiple styles can be combined using semicolons.

from sgroove import S

text = S("Hello World!")

# Applying basic colors and styles
print(f"{text:blue;bold;underlined}")

# Using RGB in f-strings
print(f"{text:rgb(0, 255, 128)}")

# Combining named colors and custom RGB background
print(f"{text:white;bg_rgb(50, 50, 50)}")

Metadata

Release files for sgroove 0.1.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 sgroove 0.1.0
File Size Uploaded Provenance
sgroove-0.1.0.tar.gz 9.0 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 20.6 kB

Release files / sgroove-0.1.0.tar.gz

Download URL sgroove-0.1.0.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d929b1ffebbbab550e14d71f99d98d5c134009a09b87dcde728340b83f9f14e3
BLAKE2b-256 checksum
How to use checksums
883ac3927a253526a8daefa9c7fbe11c022de71b154225c04cd0c62ac7b0cdac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / sgroove-0.1.0-py3-none-any.whl

Download URL sgroove-0.1.0-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b88eadc3abcea314dec9fbcb8608248a8cb7af744eab96ee6e0efdca548ad1ec
BLAKE2b-256 checksum
How to use checksums
490da6da37dbb74307d03470d8051b98206da01a57826082171f83a8de9ccb17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for sgroove 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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