On 5 October 2012 10:27, Andy Buckley firstname.lastname@example.org wrote:
A couple of weeks ago I posted a question on superuser.com about whether there is a way to get the same *very* convenient stepping-through-command-history behaviour in an interactive Python interpreter session as is possible in (at least) the bash shell with the Ctrl-o keybinding:
I was spurred to ask this question by a painful development experience full of Up Up Up Up Up Enter Up Up Up Up Up Enter ... keypresses to repeat a previous set of Python commands/statements that weren't worth putting in a script file, or which I wanted to make very minor changes to on each iteration.
As soon as I find myself doing this I quit the interpreter and start ipython. The feature that ipython has that makes what you are doing much easier is the magic %edit command. Just type
In : edit tmp.py
and your favourite editor will open up allowing you to write/edit some code. When you close the editor, ipython will run the code from tmp.py within the interactive session (as if you had typed it in directly). If you want to rerun that code with modifications just type 'edit tmp.py' again and you can make the modifications within your editor.