Pastel
Pastel is a simple Python library (current version 0.2.1) designed to bring colors to your terminal output. It provides an easy way to colorize strings using a simple tag-based syntax and comes with predefined styles like 'info' (green), 'comment' (yellow), 'question' (black on cyan), and 'error' (white on red). The library's last release was in September 2020, indicating a low release cadence and maintenance-focused status.
Warnings
- deprecated The library has not seen a new release or significant updates since September 2020. This indicates limited ongoing development, bug fixes, or security patches, which might make it unsuitable for projects requiring active maintenance or modern Python features.
- gotcha While Pastel supports Python 2.7+, Python 2 has reached its End-of-Life and is no longer supported by the Python community. Using Python 2.7 is strongly discouraged for security and compatibility reasons.
- gotcha Be careful not to confuse `sdispater/pastel` (this library) with other Python libraries that might use 'pastel' in their name or provide similar functionality, such as `catppuccin` (a soothing pastel theme library) or `sharkdp/pastel` (a Rust-based CLI tool with Python bindings that focuses on color generation and manipulation). These are distinct projects with different APIs and functionalities.
Install
-
pip install pastel
Imports
- colorize
import pastel colored_string = pastel.colorize('<info>This is an informational message.</info>')
Quickstart
import pastel
# Using a predefined style
print(pastel.colorize('<info>Information</info>'))
# Using custom foreground color and options
print(pastel.colorize('<fg=red;options=bold>This is bold red text</>'))
# Using custom background color
print(pastel.colorize('<bg=blue>Blue background</bg>'))
# Disabling colors programmatically
pastel.with_colors(False)
print(pastel.colorize('<error>This will now be uncolored</error>'))
pastel.with_colors(True) # Re-enable for subsequent calls