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")
Submodules#
- stouputils.print.color_formatting module
- stouputils.print.colorizer module
WordColorizerWordColorizer.colorWordColorizer.EXCEPTION_NAMESWordColorizer.BUILTIN_FUNCTIONSWordColorizer.KEYWORDSWordColorizer.AFFIX_PATTERNWordColorizer.QUOTED_PATTERNWordColorizer.NUMBER_PATTERNWordColorizer.WORD_SPLIT_PATTERNWordColorizer.wrap()WordColorizer.is_filepath()WordColorizer.is_number()WordColorizer.alphanumeric_of()WordColorizer.function_name_of()WordColorizer.colorize_function()WordColorizer.colorize_core()WordColorizer.colorize_word()WordColorizer.colorize_text()
- stouputils.print.common module
- stouputils.print.debugging module
- stouputils.print.message module
- stouputils.print.output_stream module
- stouputils.print.progress_tqdm module
- stouputils.print.utils module