Getting Started¶
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.
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')
Continue to the API Documentation for more information.