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?

Casebash
  • 114,675
  • 90
  • 247
  • 350
nonopolarity
  • 146,324
  • 131
  • 460
  • 740
  • 1
    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? – S.Lott Jun 28 '10 at 14:49
  • 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?" – nonopolarity Jun 29 '10 at 04:26

5 Answers5

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?

informatik01
  • 16,038
  • 10
  • 74
  • 104
shylent
  • 10,076
  • 6
  • 38
  • 55
50

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

SilentGhost
  • 307,395
  • 66
  • 306
  • 293
  • 9
    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. – nonopolarity Jun 28 '10 at 12:32
  • 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. – Adrien Plisson Jun 28 '10 at 16:08
  • Use thumb to press the right alt key, N with your index finger and P using the middle finger. Not the position. Python!! –  Dec 16 '10 at 08:29
  • You can change the letters in setting as you can see at this answer, if you don't like this specific letters https://stackoverflow.com/a/52008169/1425790 – yonilobo Feb 17 '22 at 05:24
12

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

Uyghur Lives Matter
  • 18,820
  • 42
  • 108
  • 144
Austin Cory Bart
  • 2,159
  • 2
  • 19
  • 32
11

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

Idle settings

aris
  • 22,725
  • 1
  • 29
  • 33
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.

Mortoman
  • 139
  • 3
  • 7