Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I access the command history from IDLE?

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?

like image 255
nonopolarity Avatar asked Jun 28 '10 12:06

nonopolarity


People also ask

Where is Python history stored?

The History Log is stored in the . spyder-py3 (Python 3) or spyder (Python 2) directory in your user home folder (by default, C:/Users/username on Windows, /Users/username for macOS, and typically /home/username on GNU/Linux).

How do you repeat a previous command in Python?

The usual keys: Up, Ctrl+Up, Alt-p don't work. They produce nonsensical characters. Up arrow works correctly for me (Ubuntu), it's weird. Ditto, up arrow works for me on Windows.


1 Answers

  • 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 or ipython?

like image 196
shylent Avatar answered Oct 13 '22 12:10

shylent