If you don’t want to output a Python script every time you save, or you don’t want to restart the IPython kernel:
On the command line, you can use nbconvert
:
$ jupyter nbconvert --to script [YOUR_NOTEBOOK].ipynb
As a bit of a hack, you can even call the above command in an IPython notebook by pre-pending !
(used for any command line argument). Inside a notebook:
!jupyter nbconvert --to script config_template.ipynb
Before --to script
was added, the option was --to python
or --to=python
, but it was renamed in the move toward a language-agnostic notebook system.