Misc#

Control flow#

Use mo.stop to halt execution of a cell, and optionally output an object. This function is useful for validating user input.

marimo.stop(predicate: bool, output: object | None = None) None#

Stops execution of a cell when predicate is False

When predicate is True, this function raises a MarimoStopError. If uncaught, this exception stops execution of the current cell and makes output its output. Any descendants of this cell that were previously scheduled to run will not be run, and their defs will be removed from program memory.

Example:

mo.stop(form.value is None, mo.md("**Submit the form to continue.**"))

Raises:

When predicate is True, raises a MarimoStopError.

class marimo.MarimoStopError(output: object | None)#

Raised by marimo.stop to stop execution of a cell and descendants.

Debugging#

Use mo.defs and mo.refs to get the global definitions and references of a cell.

marimo.defs() tuple[str, ...]#

Get the definitions of the currently executing cell.

Returns:

  • tuple of the currently executing cell’s defs.

marimo.refs() tuple[str, ...]#

Get the references of the currently executing cell.

Returns:

  • tuple of the currently executing cell’s refs.