5

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?

Ryan Endacott
  • 8,772
  • 4
  • 27
  • 39

2 Answers2

5

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.

Ryan Endacott
  • 8,772
  • 4
  • 27
  • 39
2

You can try with the following:

%save -a 
Matt
  • 1,313
  • 4
  • 17
  • 27