Skip to main content

Lightweight package that makes it easy and fast to print colored text in the terminal

Project description

Latest version Python 3.10 | 3.11 | 3.12 | 3.13 | 3.14+ BSD-3-Clause license Codecov CodeQL Test Downloads

🌈 Colorist for Python 🌈

Lightweight Python package that makes it easy and fast to print colored text in the terminal.

Ready to try? See how to install.

Color cube bright Color cube dark

Getting Started

Print Line of Colored Text

How to print a full line of colored text in the terminal:

from colorist import green, yellow, red

green("This is GREEN!")
yellow("This is YELLOW!")
red("This is RED!")

How it appears in the terminal:

Example of full line of green, yellow, red colored text printed in a terminal window

Print Mixed Text Colors

How to customize colors inside a paragraph and print it in the terminal:

from colorist import Color

print(f"I want {Color.RED}red{Color.OFF} color inside this paragraph")

print(f"Both {Color.GREEN}green{Color.OFF} and {Color.YELLOW}yellow{Color.OFF} are nice colors")

How it appears in the terminal:

Example of white text mixed with green, yellow, red colors printed in a terminal window

Other Styling Options

Print Bright Colors

Most terminals support bright colors that stand more out:

from colorist import BrightColor

print(f"I want {BrightColor.CYAN}cyan{BrightColor.OFF} color inside this paragraph")

How it appears in the terminal:

Example of white text mixed with cyan printed in a terminal window

Remember to use Color.OFF or BrightColor.OFF every time you want to revert back to the default terminal text style. Otherwise, the color may spill over and into other terminal messages.

Print Background Colors

from colorist import bg_green, bg_yellow, bg_red

bg_green("This is GREEN background!")
bg_yellow("This is YELLOW background!")
bg_red("This is RED background!")

How it appears in the terminal:

Example of white text and colored backgrounds if green, yellow, red printed in a terminal window

Background colors can also be mixed inside a paragraph:

from colorist import BgColor

print(f"I want {BgColor.RED}red{BgColor.OFF} background color inside this paragraph")

print(f"Both {BgColor.GREEN}green{BgColor.OFF} and {BgColor.YELLOW}yellow{BgColor.OFF} are nice background colors")

How it appears in the terminal:

Example of black, green, yellow, red background colors mixed inside paragraph printed in a terminal window

from colorist import BgBrightColor

print(f"I want {BgBrightColor.CYAN}cyan{BgBrightColor.OFF} background color inside this paragraph")

How it appears in the terminal:

Example of white text on a cyan background color printed in a terminal window

As with text colors, remember to use BgColor.OFF or BgBrightColor.OFF every time you want to revert back to the default terminal text style. Otherwise, the color may spill over and into other terminal messages.

Foreground Text

Color Full Text Function Color Code Example
Green green("text") Color.GREEN Green text color in terminal
Yellow yellow("text") Color.YELLOW Yellow text color in terminal
Red red("text") Color.RED Red text color in terminal
Magenta magenta("text") Color.MAGENTA Magenta text color in terminal
Blue blue("text") Color.BLUE Blue text color in terminal
Cyan cyan("text") Color.CYAN Cyan text color in terminal
White white("text") Color.WHITE White text color in terminal
Black black("text") Color.BLACK Black text color in terminal
- - Color.DEFAULT -
- - Color.OFF -
Bright green bright_green("text") BrightColor.GREEN Bright green text color in terminal
Bright yellow bright_yellow("text") BrightColor.YELLOW Bright yellow text color in terminal
Bright red bright_red("text") BrightColor.RED Bright red text color in terminal
Bright magenta bright_magenta("text") BrightColor.MAGENTA Bright magenta text color in terminal
Bright blue bright_blue("text") BrightColor.BLUE Bright blue text color in terminal
Bright cyan bright_cyan("text") BrightColor.CYAN Bright cyan text color in terminal
Bright white bright_white("text") BrightColor.WHITE Bright white text color in terminal
Bright black bright_black("text") BrightColor.BLACK Bright black text color in terminal
- - BrightColor.DEFAULT -
- - BrightColor.OFF -

Background

Color Full Text Function Color Code Example
Green bg_green("text") BgColor.GREEN Green background color in terminal
Yellow bg_yellow("text") BgColor.YELLOW Yellow background color in terminal
Red bg_red("text") BgColor.RED Red background color in terminal
Magenta bg_magenta("text") BgColor.MAGENTA Magenta background color in terminal
Blue bg_blue("text") BgColor.BLUE Blue background color in terminal
Cyan bg_cyan("text") BgColor.CYAN Cyan background color in terminal
White bg_white("text") BgColor.WHITE White background color in terminal
Black bg_black("text") BgColor.BLACK Black background color in terminal
- - BgColor.DEFAULT -
- - BgColor.OFF -
Bright green bg_bright_green("text") BgBrightColor.GREEN Bright green background color in terminal
Bright yellow bg_bright_yellow("text") BgBrightColor.YELLOW Bright yellow background color in terminal
Bright red bg_bright_red("text") BgBrightColor.RED Bright red background color in terminal
Bright magenta bg_bright_magenta("text") BgBrightColor.MAGENTA Bright magenta background color in terminal
Bright blue bg_bright_blue("text") BgBrightColor.BLUE Bright blue background color in terminal
Bright cyan bg_bright_cyan("text") BgBrightColor.CYAN Bright cyan background color in terminal
Bright white bg_bright_white("text") BgBrightColor.WHITE Bright white background color in terminal
Bright black bg_bright_black("text") BgBrightColor.BLACK Bright black background color in terminal
- - BgBrightColor.DEFAULT -
- - BgBrightColor.OFF -

Become a Sponsor 🏅

If you find this project helpful, please consider supporting its development. Your donations will help keep it alive and growing. Every contribution makes a difference, whether you buy a coffee or support with a monthly donation. Find your tier here:

Donate on GitHub Sponsors

Thank you for your support! 🙌

Contribute

If you have suggestions or changes to the module, feel free to add to the code and create a pull request.

Report Bugs

If you encounter any issues, you can report them as bugs or raise issues.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

colorist-1.8.12.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

colorist-1.8.12-py3-none-any.whl (46.5 kB view details)

Uploaded Python 3

File details

Details for the file colorist-1.8.12.tar.gz.

File metadata

  • Download URL: colorist-1.8.12.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for colorist-1.8.12.tar.gz
Algorithm Hash digest
SHA256 b8512dd8df8c4ce30f6faa833ddc8ec4c3ccb2e517223d187af50e199dd8104c
MD5 49ce86c98ae9e288771dd6b0d41bffe8
BLAKE2b-256 ea9d4ec39bbd727c4fdad9b8d676841178b8cb69ffa5697dc27a2852e5bedff1

See more details on using hashes here.

Provenance

The following attestation bundles were made for colorist-1.8.12.tar.gz:

Publisher: release.yml on jakob-bagterp/colorist-for-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file colorist-1.8.12-py3-none-any.whl.

File metadata

  • Download URL: colorist-1.8.12-py3-none-any.whl
  • Upload date:
  • Size: 46.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for colorist-1.8.12-py3-none-any.whl
Algorithm Hash digest
SHA256 5f26296c4eb351cebff70cb64f2ea35e6b67db7bff7af43e25455e01c9d46f02
MD5 6016321793c2d095fac30acf9735eb77
BLAKE2b-256 44b3f3b4170ecf4d169dd0495a44e6735b76c41ac0f4c6b19ebca2e75103f250

See more details on using hashes here.

Provenance

The following attestation bundles were made for colorist-1.8.12-py3-none-any.whl:

Publisher: release.yml on jakob-bagterp/colorist-for-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page