The excellent ipython notebook has a handy --script
command line flag that automatically saves a copy of the notebook as a .py
script file (removing any header and markdown cells). Is there a way to switch this feature on from inside the notebook itself after the notebook is opened? Apparently, this option is not accessible to the %config
magic.
Is there a way to have a cell that does this conversion? Is there any command-line tool I could use to do the conversion, and just have that in a shell command run from the notebook? (It seems that nbconvert does not output to .py
.)
The reason I ask is that I have a git repository of notebooks, and I need to make sure the .py
files are kept up to date when users change the notebooks themselves because the .py
files are used to create c++ code from the contents of the notebooks. But I can't rely on users to set the --script
flag because they'll always forget. (And I include myself in that group of users.)