Python colorizing strings library
A lightweight library for applying color and HTML text styles to the strings that uses the builder pattern for configuration. The ezcolor lets you have nice colorized output with extra HTML text styles like bold/italic/underline. compatible with bash/sh/zsh.
- A simple to use API
- lightweight and written in pure python
- Tested on python 3.6+ (not compatible with python2.x)
- Not compatible with windows OS (command prompt, powershell)
$ pip install ezcolor
from ezcolor import Style
style = Style()
cp = style.add.foreground('green').apply()
cp('hello world')
cp = style.add.foreground('green').background('dark_gray').bold.italic.underline.apply()
cp('hello world')
cp = style.add.foreground('green').prefix('done').bold.italic.apply()
cp('Job is done!')
cp_error = style.add.foreground('red').prefix('error').bold.italic.apply()
cp_error('Error occurred!')
@cp.decorate
def my_name(name, lastname):
return f"my name is {name} {lastname}"
print(my_name('Fardin', 'Allahverdinazhand'))
Color | prefix |
---|---|
black | done |
red | info |
green | warning |
yellow | error |
blue | |
magenta | |
cyan | |
light_gray | |
dark_gray | |
light_red | |
light_green | |
light_yellow | |
light_blue | |
light_magenta | |
light_cyan | |
white |
Fardin Allahverdinazhand - @0x0ptim0us - [email protected] Distributed under the MIT license. see LICENSE.txt for more information.