Appendix — exploiting rich __repr__ Outputs

The Python/IPython __repr__ family of methods can produce rich outputs in a display context sensitive way. In a Jupyter publishing workflow, this means that objects can return rich HTML objects, for example, that can be rendered as such as notebook code cell output.

See SubjectMatterNotebooks for a growing collection of examples of packages capable of producing rich, and often javascript interactive, content as part of a Jupyter publishing system.

# Authoring for Rich Output Environments

As well as rendering rich HTML output as a code cell output in a “live” Jupyter notbook context, notebooks, and the Jupyer server code execution machinery, can also be used to generate static HTML output documents.

For example, the Jupyter Book publishing framework can produce rich interactive HTML textbooks from Jupyter notebook “source” documents by executing the notebook code and embedding code cell outputs in an output HTML document. (Publishing controls allow the code cells to be hidden but revealable, or removed altogether, from the output HTML documents.

Jupyter notebooks can also be run and saved to various other output formats using the nbconvert command line tool. Custom templates can be applied to style the output content. Several notebooks extensions also have custom template options that allow similar effects to the extension effect to be applied to content converted to other output formats. (For example, hiding cells.)