Inspect¶
Use mo.inspect() to explore Python objects with a rich, interactive display of their attributes, methods, and documentation.
Example¶
import marimo as mo
# Inspect a class
mo.inspect(list, methods=True)
# Inspect an instance
my_dict = {"key": "value"}
mo.inspect(my_dict)
# Show all attributes including private and dunder
mo.inspect(my_dict, all=True)
marimo.inspect
¶
inspect(obj: object, *, help: bool = False, methods: bool = False, docs: bool = True, private: bool = False, dunder: bool = False, sort: bool = True, all: bool = False, value: bool = True)
Bases: Html
Inspect a Python object.
Displays objects with their attributes, methods, and documentation in a rich HTML format. Useful for exploring objects that lack a rich repr.
| PARAMETER | DESCRIPTION |
|---|---|
obj
|
The object to inspect.
TYPE:
|
help
|
Show full help text (otherwise just first paragraph).
TYPE:
|
methods
|
Show methods.
TYPE:
|
docs
|
Show documentation for attributes/methods.
TYPE:
|
private
|
Show private attributes (starting with '_').
TYPE:
|
dunder
|
Show dunder attributes (starting with '__').
TYPE:
|
sort
|
Sort attributes alphabetically.
TYPE:
|
all
|
Show all attributes (methods, private, and dunder).
TYPE:
|
value
|
Show the object's value/repr.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
|
An |
batch
¶
Convert an HTML object with templated text into a UI element.
This method lets you create custom UI elements that are represented by arbitrary HTML.
Example
user_info = mo.md(
'''
- What's your name?: {name}
- When were you born?: {birthday}
'''
).batch(name=mo.ui.text(), birthday=mo.ui.date())
In this example, user_info is a UI Element whose output is markdown
and whose value is a dict with keys 'name' and 'birthday'
(and values equal to the values of their corresponding elements).
| PARAMETER | DESCRIPTION |
|---|---|
elements
|
the UI elements to interpolate into the HTML template.
TYPE:
|
callout
¶
Create a callout containing this HTML element.
A callout wraps your HTML element in a raised box, emphasizing its
importance. You can style the callout for different situations with the
kind argument.
Examples: