needleinthehay.de

Tips for Jupyter

Pretty print all outputs

Put in notebook:

from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"

If you want to set this behavior for all instances of Jupyter, simply create a file ~/.ipython/profile_default/ipython_config.py with the lines:

c = get_config()
c.InteractiveShell.ast_node_interactivity = "all"

Toggle Code-Cells

Solution without the need of an extension that also works in HTML exports. Just put the following code in a cell and execute it:

from IPython.display import HTML
HTML('''<script>
code_show=true;
function code_toggle() {
if (code_show){
$('div.input').hide();
} else {
$('div.input').show();
}
code_show = !code_show
}
$( document ).ready(code_toggle);
</script>
The raw code for this Notebook is by default hidden for easier reading.
To toggle on/off the raw code, click <a href="javascript:code_toggle()">here</a>.''')

Extensions