[IPython-dev] Magics that have return values, $$var=cmd simplification

Ville Vainio vivainio at gmail.com
Tue Jan 24 13:53:44 EST 2006

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

> The regexp to catch these reliably is trivial (provided that var name
> is (\w+) and both are illegal python. Anyone have any
> doubt/objections? $$var = cmd syntax is there but it's not as easy to
> remember or obvious.

An extra idea - we could add a "pluggable prefilter" system a'la:

import IPython.ipapi as ip

def grab_sys_cmd_output(orig_line):
  return "%s = popen(%s).read()" % (varname, cmd)

ip.register_prefilter(r"(\w+)\s*=\s*!(.*)", grab_sys_cmd_output)

Ville Vainio - http://tinyurl.com/2prnb

More information about the IPython-dev mailing list