I\'d like to be able to \"up-arrow\" to commands that I input in a previous Python interpreter. I have found the readline
module which offers functions like:
Use PIP to install the pyreadline package:
pip install pyreadline
Persistent history has been supported out of the box since Python 3.4. See this bug report.
Try using IPython as a python shell. It already has everything you ask for. They have packages for most popular distros, so install should be very easy.
If all you want is to use interactive history substitution without all the file stuff, all you need to do is import readline:
import readline
And then you can use the up/down keys to navigate past commands. Same for 2 or 3.
This wasn't clear to me from the docs, but maybe I missed it.
I think the suggestions in the Python documentation pretty much cover what you want. Look at the example pystartup file toward the end of section 13.3:
or see this page:
But, for an out of the box interactive shell that provides all this and more, take a look at using IPython: