Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python interactive mode history and arrow keys

Tags:

python

macos

I was wondering if anyone can explain why all of a sudden in Python interactive mode all arrow keys are failing?

When I press up button for example to go through command history I get "^[[A". Same with any other arrow keys.

I have no idea why this happened and it was working before (on OS X Snow Leopard). Does anyone know a way to fix this?

Many thanks,

G

like image 761
givp Avatar asked Aug 14 '10 14:08

givp


People also ask

What are the arrow keys in Python?

K_UP , K_DOWN , K_LEFT , and K_RIGHT correspond to the arrow keys on the keyboard. If the dictionary entry for that key is True , then that key is down, and you move the player .

What is the shortcut to retrieve the previous result printed on the interactive shell?

Previously we saw that the IPython shell allows you to access previous commands with the up and down arrow keys, or equivalently the Ctrl-p/Ctrl-n shortcuts.

What do you type to enter the interactive help mode of Python?

On Windows, bring up the command prompt and type "py", or start an interactive Python session by selecting "Python (command line)", "IDLE", or similar program from the task bar / app menu.


1 Answers

If you are using homebrew, this is an easy fix:

 brew uninstall python brew uninstall readline brew install readline  --universal brew install python 

That fixed it for me (running OS X Mavericks 10.9.5)

like image 127
Hexatonic Avatar answered Oct 01 '22 14:10

Hexatonic