Registry / serialization / style
library1.1.6pypypiunverified

Style is a simple and fast Python library for styling terminal output with colors and formatting using ANSI escape codes. It provides a clean API for foreground colors, background colors, and text effects. The current version is 1.1.6, and it maintains a stable, active release cadence.

pip install style
INSTALL
IMPORT
SIG · STYLE
S
style
serializationpythonv1.1.6
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.4MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.5s · import 0.000s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

style
import style
import style

This example demonstrates basic usage of `style` to apply foreground color, background color, and text effects like bold or underline to a string. The `style` function returns the styled string, which can then be printed.

from style import style, fg, bg, ef print(style("Hello, World!", fg.red, bg.blue, ef.bold)) print(style("Underlined text.", ef.underline)) print(style("Green background.", bg.green))
Debug
Known issues
gotchaWhen applying styles using the `style()` function, inner `style()` calls effectively create new styled segments that are concatenated. This means that a parent style will not 'wrap' a child styled segment as it implicitly resets before and after each `style()` call.
fix
Apply styles to individual components and concatenate them. For example, `print(style('Hello ', fg.red) + style('World!', fg.blue))` for distinct styling, rather than `print(style('Hello ' + style('World!', fg.blue), fg.red))` which won't apply red to 'World!'.
affects: All versions (1.0.0+)
gotchaStyles (colors and effects) are applied by their lowercase attribute names (e.g., `fg.red`, `ef.bold`). Using uppercase attribute names (e.g., `fg.RED`) will result in an `AttributeError`.
fix
Always use lowercase attribute names for colors and effects as defined in the `fg`, `bg`, and `ef` objects.
affects: All versions (1.0.0+)
Upgrade
Version history
1.1.6latest on PyPI · released Mar 8, 2019
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
style — pip install style · libregistry