How do I repeat the last command? The usual keys: Up, Ctrl+Up, Alt-p don't work. They produce nonsensical characters.
(ve)[kakarukeys@localhost ve]$ python
Python 2.6.6 (r266:84292, Nov 15 2010, 21:48:32)
[GCC 4.4.4 20100630 (Red Hat 4.4.4-10)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print "hello world"
hello world
>>> ^[[A
File "<stdin>", line 1
^
SyntaxError: invalid syntax
>>> ^[[1;5A
File "<stdin>", line 1
[1;5A
^
SyntaxError: invalid syntax
>>> ^[p
File "<stdin>", line 1
p
^
SyntaxError: invalid syntax
>>>
This can happen when you run
python script.py
vs justpython
to enter the interactive shell, among other reasons for readline being disabled.Try:
Alt + p for previous command from histroy, Alt + n for next command from history.
This is default configure, and you can change these key shortcut at your preference from Options -> Configure IDLE.
Using arrow keys to go to the start of the command and hitting enter copies it as the current command.
Then just hit enter to run it again.
Up arrow works for me too. And i don't think you need to install the Readline module for python builtin commandline. U should try Ipython to check. Or maybe it's the problem of your keybord map.
In IDLE, go to Options -> Configure IDLE -> Keys and there select history-next and then history-previous to change the keys.
Then click on Get New Keys for Selection and you are ready to choose whatever key combination you want.
In my mac os python3 you can use: control+p early command contrlo+n next command