Colorist for Python
Project description
🌈 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.
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:
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:
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:
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:
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:
from colorist import BgBrightColor
print(f"I want {BgBrightColor.CYAN}cyan{BgBrightColor.OFF} background color inside this paragraph")
How it appears in the terminal:
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 | Custom | Example |
---|---|---|---|
green("text") |
Color.GREEN |
||
yellow("text") |
Color.YELLOW |
||
red("text") |
Color.RED |
||
magenta("text") |
Color.MAGENTA |
||
blue("text") |
Color.BLUE |
||
cyan("text") |
Color.CYAN |
||
white("text") |
Color.WHITE |
||
black("text") |
Color.BLACK |
||
- | - | Color.DEFAULT |
- |
- | - | Color.OFF |
- |
bright_green("text") |
BrightColor.GREEN |
||
bright_yellow("text") |
BrightColor.YELLOW |
||
bright_red("text") |
BrightColor.RED |
||
bright_magenta("text") |
BrightColor.MAGENTA |
||
bright_blue("text") |
BrightColor.BLUE |
||
bright_cyan("text") |
BrightColor.CYAN |
||
bright_white("text") |
BrightColor.WHITE |
||
bright_black("text") |
BrightColor.BLACK |
||
- | - | BrightColor.DEFAULT |
- |
- | - | BrightColor.OFF |
- |
Background
Color | Full Text Function | Custom | Example |
---|---|---|---|
bg_green("text") |
BgColor.GREEN |
||
bg_yellow("text") |
BgColor.YELLOW |
||
bg_red("text") |
BgColor.RED |
||
bg_magenta("text") |
BgColor.MAGENTA |
||
bg_blue("text") |
BgColor.BLUE |
||
bg_cyan("text") |
BgColor.CYAN |
||
bg_white("text") |
BgColor.WHITE |
||
bg_black("text") |
BgColor.BLACK |
||
- | - | BgColor.DEFAULT |
- |
- | - | BgColor.OFF |
- |
bg_bright_green("text") |
BgBrightColor.GREEN |
||
bg_bright_yellow("text") |
BgBrightColor.YELLOW |
||
bg_bright_red("text") |
BgBrightColor.RED |
||
bg_bright_magenta("text") |
BgBrightColor.MAGENTA |
||
bg_bright_blue("text") |
BgBrightColor.BLUE |
||
bg_bright_cyan("text") |
BgBrightColor.CYAN |
||
bg_bright_white("text") |
BgBrightColor.WHITE |
||
bg_bright_black("text") |
BgBrightColor.BLACK |
||
- | - | BgBrightColor.DEFAULT |
- |
- | - | BgBrightColor.OFF |
- |
Thank You for Supporting
Donate
This module is free to use. And if you like it, feel free to buy me a coffee.
Contribute
If you have suggestions or changes to the module, feel free to add to the code and create a pull request.
Report Bugs
Report bugs and issues here.
3-Clause BSD License
Copyright (c) 2022 – present, Jakob Bagterp
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-
Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file colorist-1.8.1.tar.gz
.
File metadata
- Download URL: colorist-1.8.1.tar.gz
- Upload date:
- Size: 21.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b11a7c5fe18766c31be6c374718051c3795b70b4508f4ae2b315f46781dbf1c |
|
MD5 | 5582fb2c0774b7e586a1eb6a8c85bc3c |
|
BLAKE2b-256 | a32a9927524af53886e5aa14d2364b141df3a88a1b5d9b41fc72892ed353680d |
File details
Details for the file colorist-1.8.1-py3-none-any.whl
.
File metadata
- Download URL: colorist-1.8.1-py3-none-any.whl
- Upload date:
- Size: 39.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebabaa9ab686ee3fea66fd17b4e7c5ab900819a6285dda5d1c4ba0c0e75b29bf |
|
MD5 | d3d6324180d9b181fd28fc3c47768612 |
|
BLAKE2b-256 | 31bc8af8d23fbd4aa9bceec9ee832784ab352cb1818242ed78774946d57e37dc |