stouputils.print package#

This module provides utility functions for printing messages with different levels of importance.

If a message is printed multiple times, it will be displayed as “(xN) message” where N is the number of times the message has been printed.

The module also includes a colored() function, which colors text in the Python 3.14 style: file paths, line numbers and function names in magenta, and exception names in bold magenta. All functions have their colored counterparts with a ‘c’ suffix (e.g., infoc(), debugc(), etc.)

import stouputils as stp

# The same message several times in a row shows once, with (x3)
for _ in range(3):
        stp.info("Downloading", "dataset.zip")

# One function per level, each with its own color
stp.debug("Cache hit for", "model.pt")
stp.suggestion("Pass num_workers=8 to load faster")
stp.progress("Epoch 3/10 done")
stp.warning("Learning rate looks high")
stp.error("Checkpoint not found", exit=False)  # exit=True would also stop the program

# Describe any value: its type, its size and its content
stp.whatisit({"lr": 0.1, "epochs": 10})

# The "c" versions highlight exception names, line numbers and file paths
stp.infoc("ValueError raised in load_data() at line 42 of ./train.py")
Terminal output of the example, each level in its own color

Submodules#