Blessings

1.7 · maintenance · verified Sat Apr 11

Blessings is a thin, practical Python wrapper around terminal capabilities, offering an elegant interface for coloring, styling, and positioning text. It aims to simplify advanced terminal interactions compared to raw ANSI escape codes or the `curses` library, handling common cases like output redirection gracefully. The latest version, 1.7, was released in June 2018. The project is largely unmaintained, with active development continuing in a fork called `blessed`.

Warnings

Install

Imports

Quickstart

Initialize the Terminal object and use its attributes for styling. The `location` context manager allows temporary cursor movements. Check `term.does_styling` for graceful degradation when output is piped to a non-terminal.

from blessings import Terminal

term = Terminal()

# Basic styling
print(term.bold_red_on_yellow('Hello, Blessings!'))

# Temporary cursor positioning
with term.location(x=0, y=term.height - 1):
    print(term.underline('This text is at the bottom.'))

# Clear the screen
# print(term.clear)

# Example of does_styling for graceful degradation
if term.does_styling:
    print(term.bold('Terminal supports styling!'))
else:
    print('Terminal does not support styling, printing plain text.')

view raw JSON →