plt.show() or display(), or when the last line of a cell evaluates to a value, the kernel emits an output message. Each of those messages becomes a Result object inside execution.results. The Result holds all the MIME representations that the kernel provided for that output.
The Result object
execution.results is a list[Result]. Each Result exposes known MIME types as named fields:
| Field | MIME type | Notes |
|---|---|---|
text | text/plain | Plain text representation. |
html | text/html | HTML representation. |
markdown | text/markdown | Markdown representation. |
svg | image/svg+xml | SVG markup string. |
png | image/png | Base64-encoded PNG. |
jpeg | image/jpeg | Base64-encoded JPEG. |
pdf | application/pdf | Base64-encoded PDF. |
latex | text/latex | LaTeX string. |
json | application/json | Parsed as a dict. |
javascript | application/javascript | JavaScript string. |
extra | (any other MIME type) | dict[str, str] of unrecognized MIME types. |
None. Check a field before using it.
Checking available formats
Callresult.formats() to get a list of the field names that are populated for a given result.
The main result flag
EachResult has an is_main_result boolean. It is True for the execute_result message — the value of the last expression in the cell. It is False for display_data messages produced by plt.show(), display(), and similar calls. The execution.text convenience property returns the text field of the main result.
Matplotlib example
Iterating and decoding outputs
String expression values have their surrounding quotes stripped automatically. If a cell evaluates to
'hello', result.text is hello, not 'hello'.