Command-line tool able to take multiple commands at one time?

Fernando Perez fperez.net at gmail.com
Fri Nov 11 00:14:12 EST 2005


Peter A.Schott wrote:

> Per subject - I realize I can copy/paste a line at a time into an interactive
> session when I'm trying to debug, but was wondering if there is any tool out
> there that allows me to copy sections of working Python scripts to paste into
> my interactive console and let those run so I don't have to copy line-by-line.
> 
> Not sure if iPython would meet that criteria or not or even if such a beast
> exists.  It would be helpful for debugging some of my simpler, yet still
> lengthy at times, scripts.

ipython has a %run command designed precisely to do this.  You can keep your
favorite editor open and work on your code.  You just need to save and type
into ipython 'run scriptname', to re-execute the code each time just as if
you'd typed it.  Note that ipython uses readline, so you just need to type 'r'
and hit the up-arrow key to retrieve the previous command starting with the
letter r.

Type 'run?' (without the quotes) into ipython to get the gory details on the run
command, or have a look at the manual here (scroll down to the %run part):

http://ipython.scipy.org/doc/manual/node6.html#SECTION00062100000000000000

Feel free to ask further questions on the ipython list, I don't keep up with
c.l.py too well these days, unfortunately.

Cheers,

f




More information about the Python-list mailing list