Skip to main content

Colorido

Colors for Terminal without weird code.

Description

Colorido is a small Python 3.x lib to speed up the text coloring throughout your Python projects. You ever can make your logs prettier. ;)

You don't need to install any dependency to use colorido. In a nutshell, just import the color module from the colorido package and call the functions in a print context to start coloring your strings.

Installation

Install it with pip by running:

pip install colorido

Usage

To use the colorido abilities, import the color module in your code and just call the function with the color you want to print. See how in the example below:

from colorido import color

print('This is the color ' + color.red('red') + '.')

Coloring

You can choose the color you want among the eight available color options. The supported options are:

Text color Function
Black black(str)
Blue blue(str)
Cyan cyan(str)
Green green(str)
Magenta magenta(str)
Red red(str)
White white(str)
Yellow yellow(str)

ℹ️ Note: the visual colors may vary according with the configuration of your Terminal or system.

Basic examples

Below we have some examples of colorido's general usage.

Example 1:

from colorido import color

text = color.green('BR') + color.yellow('AZ') + color.blue('IL')
print('Come to visit %s.' % text)

Example 2:

from colorido import color

print(f'sudo {color.red("rm -rf /")}')

Example 3:

from colorido import color

print(
    'Is zebra {black} with {white} stripes or {white} with {black} stripes?'.format(
        black=color.black('BLACK'),
        white=color.white('WHITE'),
    )
)

Styling

Colorido also support text styling. The styles modify the heavy of the text. The supported styles are:

  • Dim text
  • Normal text
  • Bold text

You can style your text by passing an extra optional style parameter to the color functions. For example, to get a bold red text, you can do:

Example 4:

from colorido import color

print(color.red('STOP', style='bold'), 'deploys at friday!')

You can also omit the style keyword and pass the style parameter just like a positional parameter.

Example 5:

from colorido import color

print(color.magenta('Dimmed', 'dim'), 'texts are calm.')

Colorido supports three types of text styling.

Text style Parameter
Dim 'd' or 'dim'
Normal 'n' or 'normal' (default)
Bold 'b' or 'bold'

If you don't want to color your text, you can use the font() function to skip the text coloring. For this, provide the desired style parameter just like you do in the coloring functions. See how:

Example 6:

from colorido import color

print(
    '{I} {love} {linux}.'.format(
        I=color.font('I', 'bold'),
        love=color.red('<3', 'bold'),
        linux=color.font('Linux', 'dim'),
    )
)

Background color

New in version 1.0.0!

You can also color the background of your logs! Just provide a bg parameter to any color function with the name of the color you want.

Example 7:

from colorido import color

print(
    'The sun rules the {day} and the moon rules the {night}.'.format(
        day=color.yellow('day', bg='white'),
        night=color.blue('night', bg='black'),
    )
)

The available background colors are the same eight available in the foreground text colors. Below you have a list with the color options:

Background color Parameter
Black 'black'
Blue 'blue'
Cyan 'cyan'
Green 'green'
Magenta 'magenta'
Red 'red'
White 'white'
Yellow 'yellow'

If you want to use just the background color, with no foreground text color, you can call again the font() function, providing the bg parameter. For example:

Example 8:

from colorido import color

print(
    'If your {code} have many {bugs}, you propably need more {coffee}.'.format(
        code=color.font('code', bg='blue'),
        bugs=color.font('bugs', bg='red'),
        coffee=color.font('coffee', bg='black'),
    )
)

You can also style your text while you choose your background color, just like we have done in styling section. See an example:

Example 9:

from colorido import color

print(
    'The {white} {light} can split in a beautiful {ra}{i}{n}{b}{o}{w}.'.format(
        # We can style and also background our text with font() function
        white=color.font('white', 'bold', bg='white'),
        light=color.font('light', 'bold', bg='black'),
        ra=color.red('ra'),
        i=color.yellow('i'),
        n=color.green('n'),
        b=color.cyan('b'),
        o=color.blue('o'),
        w=color.magenta('w'),
    )
)

That's all folks! Bugs, questions or coffees, feel free to reach me in my e-mail.

Who is this lib for?

Colorido is addressed to anyone who wants a simple lib to print colored texts in the screen without a hundred of things to learn. You just need to import the module and call the functions you want to.

Colorido doesn't match programmers that want a full-featured lib. It just returns colored texts to be printed in the screen. No things more. If this is not your vibe, consider search for other python libraries (like colorama, colored or PyColor).

License

This lib is a free software and is distributed under the MIT License.

Metadata

Release files for colorido 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for colorido 1.0.0
File Size Uploaded Provenance Actions
colorido-1.0.0.tar.gz 7.0 kB Without provenance Details for colorido-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for colorido 1.0.0
File Interpreter ABI Platform Actions
colorido-1.0.0-py3-none-any.whl Python 3 none any Details for colorido-1.0.0-py3-none-any.whl

Total release size: 14.5 kB

Release files / colorido-1.0.0.tar.gz

Download URL colorido-1.0.0.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4285733bd0a170f05933737206e28768470c3e1517d4a1e0079471e68a9b3cc7
BLAKE2b-256 checksum
How to use checksums
2b9a6d18a6c7685896329cdd1ab5272fd1e58d1cc026a8ccefc289489b8f91c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / colorido-1.0.0-py3-none-any.whl

Download URL colorido-1.0.0-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
96106213bea94ce1a9f3511335bff5d46f86eae104204a28a371b80d6f124dbf
BLAKE2b-256 checksum
How to use checksums
3f77377cc83d4952a3f455a06ce0a06070a1c569a6bf16a7c1812e9f236f935e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Security for colorido 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page