Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I save the code written in an IPython session? [duplicate]

Tags:

python

ipython

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.

like image 702
Samuel Lampa Avatar asked Nov 29 '12 14:11

Samuel Lampa


People also ask

How do you save codes on IPython?

Save an iPython session commands/code to a file. You must use the magic method %save : In [1]: %save?

How do I save an interactive session in Python?

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.

How do I save a Python file in IPython?

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.

How do I save a file in Python shell?

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.


1 Answers

%save my_useful_session 10-20 23

to save input lines 10 to 20 and 23 to my_useful_session.py

like image 89
Samuel Lampa Avatar answered Sep 27 '22 21:09

Samuel Lampa