[IPython-user] alias / macro question

Ville M. Vainio vivainio at gmail.com
Fri Dec 1 07:45:31 CST 2006

On 12/1/06, Ville M. Vainio <vivainio at gmail.com> wrote:

> > At first I thought %alias might work, but alas, the manual tells me
> > it is only for system shell commands.
> You could try something like:

... snip...

Or a slightly more heavyweight solution: define your own magic command:

----- file impall.py --------

import IPython.ipapi
ip = IPython.ipapi.get()

def doimp(self, arg):
    self.api.ex("import %s; reload(%s); from %s import *" % (

ip.expose_magic('imp', doimp)


And then add "import impall" to your .ipython/ipy_user_conf.py. After
that, you can do "%imp foo" for the effect you want.

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

More information about the IPython-user mailing list