r/IPython • • Sep 20 '15

Easiest way to hide your input in code cells

http://blog.nextgenetics.net/?e=102
12 Upvotes

1 comment sorted by

1

u/NomadNella Sep 20 '15

In summary just add and execute the following.

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 IPython notebook is by default hidden for easier reading.
To toggle on/off the raw code, click <a href="javascript:code_toggle()">here</a>.''')

This will work for hiding inputs in slide shows as well.