A lightweight, tagged, and color-coded Python 3 print alternative

pip install PrintTags==1.5.1


Build Status Documentation Status Pypi Version Issues Status Coverage Status License

PrintTags is a lightweight package designed to act as an alternative to the built-in Python 3 print function. It prints color coded, tagged messages that can be useful in debugging, or if you just prefer a cleaner appearance in your terminal.

Basic Usage:

First, install PrintTags using pip:

$ pip install PrintTags

Then simply import it, and call the desired print function:

import PrintTags as pt

pt.info('My message')

There are also color methods that will print a colored message directly:

pt.green('My message')


PrintTags is designed to be backward compatible with Python's default print function. This means all functions within the PrintTags namespace accept the same keyword arguments as print:

pt.success('positional', 'arguments', sep=' ', end='\n', file=None, flush=True)

These functions also include additional keyword arguments that are used to customize the output:

# Prints using a user defined tag
pt.success('positional', 'arguments', tag='[custom_success]')
# Prepends a datetime stamp to the output
pt.success('positional', 'arguments', add_datetime=True)
# Prepends a prefix value to the output. This will not be 
# treated as a positional argument and therefore will not be
# separated by "sep" argument.
pt.success('positional', 'arguments', prefix='some_prefix')
pt.success('positional', 'arguments', prefix='some_prefix')


All methods listed above will colorize the input string and print it to the console. If you need only to colorize a string without printing it, just import the Colors module and call the appropriate color method:

from PrintTags import Colors

# Will return "My message" wrapped in the associated ANSI escape code
blue_message = Colors.blue('My message')

PrintTags is designed to be fast, transparent, and simple. Its mission is to extend Python's print function and have the smallest learning curve possible. To this end, it does not aspire to be a full-featured logging library. For users who require a more in-depth logger, perhaps Python's built-in logging might be of interest. There are also a number of open-source alternatives that are quite exceptional, namely Loguru.

For a full API reference, read the docs

Example Output:


View license file