Wasabi
Wasabi is a lightweight console printing and formatting toolkit designed by Explosion, the creators of spaCy. It aims to make console output more readable and visually appealing with minimal overhead. The library is currently at version 1.1.3 and is actively maintained, receiving regular updates often in conjunction with other Explosion projects.
Warnings
- breaking Wasabi dropped support for Python 3.5 and earlier versions starting from v1.1.0. Ensure your environment uses Python 3.6 or newer.
- gotcha The `Printer.fail()` method, when called with `exits=True` or `exits=1`, will terminate the script by calling `sys.exit()` after printing. This is useful for critical failures but can halt execution prematurely if not intended.
- gotcha The `from wasabi import msg` object is a pre-configured `Printer` instance. If you need custom settings (e.g., `pretty=False`, different colors), you must instantiate `from wasabi import Printer` directly.
- gotcha Wasabi is designed to be lightweight and specific for console output by Explosion's projects. For highly complex or full-featured formatting needs, consider alternative, more general-purpose libraries.
Install
-
pip install wasabi
Imports
- Printer
from wasabi import Printer
- msg
from wasabi import msg
Quickstart
from wasabi import Printer
# Instantiate a Printer for custom configuration
msg = Printer(pretty=True, hide_tags=False)
msg.text("Starting application...", icon="🚀")
msg.good("Configuration loaded successfully.")
msg.warn("API key not found, running in limited mode.")
msg.fail("Database connection failed.")
# Print a divider
msg.divider("Summary")
# Using the global 'msg' instance (pre-configured)
from wasabi import msg as default_msg
default_msg.info("Default printer message.")