[IPython-user] ipython -p sh questions

Ville M. Vainio vivainio@gmail....
Tue Mar 4 11:28:12 CST 2008


On Tue, Mar 4, 2008 at 6:44 PM, James Spencer <jss43@cam.ac.uk> wrote:

> > There is a syntax for this:
>  >
>  > o = !some_command foo bar
>
>
> Cheers.  I was being lazy and trying to avoid the extra keystrokes. :-)
>   Plus, it would be nice if it was possible (but maybe not default) to be
>  able to handle output from python and shell commands in exactly the same
>  way.

Could be done. jobctrl.py extensios is used for "advanced job
control", and it already sets its own shell command hook, using
subprocess (on order to support %tasks and %kill). We could perhaps
add a magic command there that sets "outputcapturing" (or somesuch)
flag, which causes the hooked function to capture output to IPython
output history.

I am rather busy ATM, but I could take a brief stab at it.

> > What does !$ do? If there in no equivalent yes, we can do it ;-)

> !$ designates the last argument of the preceding command.  (!!:n
>  designates the n-th argument of the preceding command).  I thought about
>  adding it to my config files but I'm always loathe to hack things in
>  when someone might've already done it better. :-)

Ah, such a thing does not exist but it could be useful. Hell, we could
add it to jobctrl as well. $! does not sit well in IPython due to Itpl
interpolation (even if it could be done with prefilters), but $LA
could be handy for this purpose. I.e. in jobctrl shell hook we could
set global variable LA in user_ns to have the last arg, and $LA will
naturally work.

-- 
Ville M. Vainio - vivainio.googlepages.com
blog=360.yahoo.com/villevainio - g[mail | talk]='vivainio'


More information about the IPython-user mailing list