Possible Duplicate:
How to save a Python interactive session?
Is it possible, and if so, how do I save the code that I have written in an IPython session?
Optimally I would only output the code that runs without errors, but exporting all the code would go a long way as well, I suppose.
Save an iPython session commands/code to a file. You must use the magic method %save : In [1]: %save?
To save a Python interactive session, we can use the readline module. to call readline. write_history_file to save the interactive session content into the /home/ahj/history file.
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.
Right-click the Python window and select Save As to save your code either as a Python file (. py) or Text file (. txt). If saving to a Python file, only the Python code will be saved.
%save my_useful_session 10-20 23
to save input lines 10 to 20 and 23 to my_useful_session.py
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