In IPython, you can save parts of the current session by doing %save my_useful_session 10-20 23
to save lines 10-20 and line 23 to the file my_useful_session.py
. If my_useful_session.py
already exists, IPython promps you to overwrite the fail rather than append it. How can you append to an already existing file?
You can save your IPython session to a file with the %save command.
Append and Read ('a+') : Open the file for reading and writing. The file is created if it does not exist. The handle is positioned at the end of the file. The data being written will be inserted at the end, after the existing data.
Saving a Jupter notebook Saving your edits is simple. There is a disk icon in the upper left of the Jupyter tool bar. Click the save icon and your notebook edits are saved.
I found the answer in this GitHub pull request. You can append to an existing file by passing the -a
option to the save command. Note that the option must be passed before any of the other input. Ex: %save -a my_useful_session 10-20 23
will append lines 10-20 and 23 to the file my_useful_session.py
.
You can try with the following:
%save -a
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