How do I access the command history from IDLE?

PythonPython Idle

Python Problem Overview


On bash or Window's Command Prompt, we can press the up arrow on keyboard to get the last command, and edit it, and press ENTER again to see the result.

But in Python's IDLE 2.6.5 or 3.1.2, it seems if our statement prints out 25 lines, we need to press the up arrow 25 times to that last command, and press ENTER for it to be copied?

Or use the mouse to pinpoint that line and click there, and press ENTER to copy? Is there a faster way?

Python Solutions


Solution 1 - Python

  • I think you are looking for the history-previous action, which is bound to Alt+P by default.
  • You can remap it in "Options -> Configure IDLE -> Keys"
  • You can also access this command from the top menu in IDLE: "Shell -> Previous History"

Incidentally, why don't you try a better (less ugly, for starters) shell like [bpython][1] or [ipython][2]?

[1]: http://bpython-interpreter.org/ "bpython" [2]: http://ipython.org/ "ipython"

Solution 2 - Python

just use Alt+P to go up. Similarly, Alt+N could be used to go down.

Solution 3 - Python

If you're on mac, it's ctrl+p.

Solution 4 - Python

Go into Preferences > Keys. Find the 'history-previous' selection in the list and edit it to Up Arrow.

Idle settings

Solution 5 - Python

You can always edit the file config-keys.cfg found under ~/.idlerc by default; look for the entry "history-previous" and set it to as below...

history-previous = <Key-Up>

Done.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionnonopolarityView Question on Stackoverflow
Solution 1 - PythonshylentView Answer on Stackoverflow
Solution 2 - PythonSilentGhostView Answer on Stackoverflow
Solution 3 - PythonAustin Cory BartView Answer on Stackoverflow
Solution 4 - PythonarisView Answer on Stackoverflow
Solution 5 - PythonMortomanView Answer on Stackoverflow