print

Caliber implements a custom print function which can be swapped with the builtin print or rich.print. If the custom print function is used in a repl, or in a Workflow which is not run from the CLI, it behaves as rich.print, i.e. like the builtin print, but with support for displaying rich renderables and console markup. If the function is used in a Workflow which is run from the CLI, it behaves as rich.print, only displaying the printed objects in the task activity panel.


caliber.print(*objects: Any, sep: str = ' ', end: str = '\n', file: IO[str] | None = None, flush: bool = False)[source]

Print object(s) supplied via positinal arguments.

This function has an identical signature to the built-in print, and therefore also to rich.print, so that it can be swapped.

If the function is called with an active CaliberApp, the objects are printed to the task activity panel. If there is no active CaliberApp, the objects are printed as with rich.print.

Note that this function is automatically swapped with the builtin print and rich.print if any of those are used in a workflow.

Parameters:
  • objects (any) – One or more objects to be printed.

  • sep (str) – Separator between printed objects. Defaults to ‘ ‘.

  • end (str) – Character to write at the end of output. Defaults to ‘\n’.

  • file (IO[str]) – File to write to, or None for stdout. Defaults to None.

  • flush (bool) – Has no effect since Rich is used and Rich always flushes output. Defaults to False.