Lesson 9 Discussion & Wiki (2019)

@jeremy, if you’d like to replace the hardcoded cells in each dev_nbs such as:

!./notebook2script.py 02_fully_connected.ipynb

with just:

nb_auto_export()

add this into the first nb export, so that it’s imported everywhere.

from IPython.display import display, Javascript
def nb_auto_export():
    display(Javascript("if (IPython.notebook.kernel) { IPython.notebook.kernel.execute('!./notebook2script.py  ' + IPython.notebook.notebook_name )}"))

or w/o needing to import anything, just this js magic cell:

%%javascript 
if (IPython.notebook.kernel) {
    IPython.notebook.kernel.execute('!./notebook2script.py ' + IPython.notebook.notebook_name)
}

More details are here.

edit: had to add if (IPython.notebook.kernel) {} or it’d fail on nb load.

1 Like