Search code examples
pythonpython-3.xcurses

How can I use readline to enable the user to "scroll" to previously entered lines?


I have a command-line application that works similarly to a shell in that is continuously asks the user for a command and performs a certain action based on the command given. I'd like to implement the "scroll-back" or "history" feature to allow users to use the up and down arrow keys to navigate to and from previously entered lines. I have previously browsed the docs but can't figure it out. Any pointers?


Solution

  • Wow. I didn't think it'd be answered in the docs but it is. Another reason why I love Python. http://docs.python.org/py3k/library/readline.html