VividHues: Super light Python string formatter! 🌈 📦
📝 Note!
This requires Bash to be installed on your OS. Git Bash or WSL are two of many to pick from!
👉 Replit installation instructions in here! 👈
- Upload the installer script to your project's file system
- Run
bash install_vividhues.sh
in the shell
👉 Manual installation instructions in here! 👈
$ pip install VividHues
pip install --upgrade VividHues
from VividHues import Clr
VividHues>=5.3.0
VividHues>=3.0.0 # basics: only has Clr codes
VividHues>=4.1.0 # new: abbreviations & "Magic Functions"
VividHues>=5.2.0 # Magic Function: Clr.pattern()
VividHues>=5.3.0 # all Magic Functions no longer leak color
VividHues>=5.4.0 # Clr.delPrevLine()
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
# recommended
COPY requirements.txt .
RUN pip install -r requirements.txt
# alternatively...
RUN pip install VividHues
print(Clr.BO + Clr.UL + Clr.rainbow('I love VividHues!'))
print(Clr.RED + "It's got my fave color!" + Clr.RS)
print(f"Soooo {Clr.jazzy('jazzy')}")
# ^^^
# you'll get an error using "" in f-string interpolations
print(Clr.pattern("Kenny Oliver", Clr.PURPLE, Clr.CYAN, Clr.LIME))
👉 Color leakage is when you have forgotten to use Clr.RS
/Clr.RESET
👈 to reset the formatting after the last character printed to the standard output!
It results in any trailing characters, in the output stream, to continue to have the same formatting.
This is an intentional feature, because it allows for the formatting of entire chunks of code in one go. See the example
As of
VividHues>=5.3.0
, ALL magic functions do not leak color.Previously, it was only
Clr.random()
!
print(... + Clr.RS) # recommended!
print(..., Clr.RS)
print(..., end=Clr.RS+"\n")
# start formatting here
print(Clr.BOLD + Clr.RED, end="")
if something:
print(Clr.BLUE + "blah blah blah" + Clr.RS)
else:
for x in range(100):
# lots of print statements
# end formatting here
print(Clr.RS, end="")
These solutions also prevent the leakage of other formatting
(e.g.
Clr.BO
,Clr.BOLD
,Clr.UL
,Clr.UNDERLINE
)
from VividHues import Clr
so that you can useClr.___
VividHues provides you with a quick way to erase the last line of the CLI!
# Delete the last printed line of the CLI
Clr.delPrevLine()
# Delete the last 5 printed lines
Clr.delPrevLine(5)
print( Clr.random(string) )
print( Clr.jazzy(string) )
print( Clr.rainbow(string) )
print( Clr.pattern(string, *color) )
Feature | VividHues | Colorama | termcolor |
---|---|---|---|
Simplicity/Abstraction | ⭐ | ⭐ | ⭐ |
Font Colors | ⭐ | ⭐ | ⭐ |
Background/Highlight | 🤞 | ⭐ | ⭐ |
Bold/Underline | ⭐ | ⭐ | |
Most Lightweight | ⭐ | ||
Auto-Reset | ⭐ | ⭐ | ⭐ |
Cursor Positioning | ⭐ | ||
Special/Unique Features | ⭐ | ⭐ | |
Total | 6/8 | 5/8 | 6/8 |
Potentially, VividHues will have more features than the alternatives if they are implemented.
import VividHues # different import this time!
print(VividHues.__author__)
# Kenneth Oliver ©2022
print(VividHues.__desc__)
# Super lite package for colored strings in Python! 🌈 📦
print(VividHues.__homepage__)
# https://github.com/KennyOliver/VividHues
print(VividHues.__package__)
# VividHues
print(VividHues.__pypi__)
# https://pypi.org/project/VividHues/
print(VividHues.__name__)
# VividHues
Kenny Oliver ©2021