How do I access the command history from IDLE?
Asked Answered
P

5

115

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?

Publication answered 28/6, 2010 at 12:20 Comment(2)
This questions title seems to have one answer: "That's the way it is". I don't think I understand the question. The body of the question ("Is there a faster way?") doesn't match the title at all. Can you edit the title to have it make sense?Kazan
well, the question title is just "how come seemingly needs to press up arrow key many times (instead of once like in Bash)" -- and then in the content, "is there a faster way?"Publication
P
156
  • 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?

Party answered 28/6, 2010 at 12:25 Comment(0)
K
50

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

Krasner answered 28/6, 2010 at 12:25 Comment(4)
ALT P and ALT N, i tried it... it seems like it is designed to see how used to you are spreading your index and middle fingers apart.Publication
use any one of your thumbs to press the ALT key, that will make this bug go away ! and remember that the keyboard was designed to use every fingers of your 2 hands.Kolosick
Use thumb to press the right alt key, N with your index finger and P using the middle finger. Not the position. Python!!Electrolyse
You can change the letters in setting as you can see at this answer, if you don't like this specific letters https://mcmap.net/q/188176/-how-do-i-access-the-command-history-from-idleHecate
W
12

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

Woodbridge answered 6/11, 2014 at 17:27 Comment(0)
P
11

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

Idle settings

Phobos answered 24/8, 2018 at 16:8 Comment(0)
C
5

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.

Celibacy answered 13/12, 2016 at 22:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.