Is there a way to tell the interactive Python shell to preserve its history of executed commands between sessions?
While a session is running, after commands have been executed, I can arrow up and access said commands, I’m just wondering if there is some way for a certain number of these commands to be saved until the next time I use the Python shell.
This would be very useful since I find myself reusing commands in a session, that I used at the end of the last session.
Sure you can, with a small startup script. From Interactive Input Editing and History Substitution in the python tutorial:
From Python 3.4 onwards, the interactive interpreter supports autocompletion and history out of the box: