Jay Taylor's notes
back to listing indexshell - How to save a Python interactive session? - Stack Overflow
[web search]
I find myself frequently using Python's interpreter to work with databases, files, etc -- basically a lot of manual formatting of semi-structured data. I don't properly save and clean up the useful bits as often as I would like. Is there a way to save my input into the shell (db connections, variable assignments, little for loops and bits of logic) -- some history of the interactive session? If I use something like UPDATE: I am really amazed at the quality and usefulness of these packages. For those with a similar itch:
I am converted, these really fill a need between interpreter and editor.
| ||||
add comment | ||||
IPython is extremely useful if you like using interactive sessions. For example for your usecase there is the save command, you just input save my_useful_session 10-20 23 to save input lines 10 to 20 and 23 to my_useful_session.py. (to help with this, every line is prefixed by its number) Look at the videos on the documentation page to get a quick overview of the features. | |||||||||||||||||||||||||||||||||
|
There is a way to do it. Store the file in ~/.pystartup
You can also add this to get autocomplete for free:
Please note that this will only work on *nix systems. As readline is only available in Unix platform. | |||||||||||||||||||||||||||||||||
|
Also, reinteract gives you a notebook-like interface to a Python session. | |||||||||
|
In addition to IPython, a similar utility bpython has a "save the code you've entered to a file" feature | |||||||||
|
On windows, PythonWin is a lot more productive than that the default python terminal. It has a lot of features that you usually find in IDEs:
You can download it as part of Python for Windows extensions http://sourceforge.net/projects/pywin32/files/pywin32/ | |||
add comment |
http://www.andrewhjon.es/save-interactive-python-session-history
| |||
add comment |
Just putting another suggesting in the bowl: Spyderlib | |||
add comment |