I'm creating a Django tutorial in an IPython Notebook and I want to use the %save
magic to save .py
files to create / edit / advance a website as the tutorial progresses. The problem is the %save
magic works by specifying which lines to save. Undoubtedly, the line number will change when users execute the cells before the file out of order or multiple times.
I'd like to work like this:
some .py file imported into the notebook.
# do all sorts of website things
%save -f this.py file
where it would save the contents of the cell without needing the line number. Is there any way to do this with the existing functionality of the %save
magic?
After talking with the IPython dev team minrk found an answer:
%%writefile filename.py
will write everything below it in the cell to filename.py
. link to the converastion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With