[IPython-dev] Macro redesign
Ville M. Vainio
vivainio at gmail.com
Thu May 3 16:23:52 EDT 2007
Some post-0.8.2 brainstorming:
I am not sure I like the current approach to macros. They have a
"special" role Prompts.cachedoutput (if output is a macro, it gets
called):
if isinstance(arg,Macro):
print 'Executing Macro...'
# in case the macro takes a long time to execute
Term.cout.flush()
self.shell.runlines(arg.value)
return None
I think Macro class should have __call__(m_arg), and get called
normally via 'autocall' mechanism.
Or we could add some extra code that always calls macros, even when
autocall is off. IpyAutocallMixin subclass, perhaps?
The rationale? Apart from abstract ideas like avoiding "special
casing", I'd like to pass arguments to macros, and return values from
them. This makes sense when you think how you'd normally write a small
"script" - run some commands, then %edit the macro.
You would access m_arg through itpl syntax ($m_arg), and return values
through assigning to special variable called m_ret.
This would allow using macros for many things you need to write
functions, magics or aliases now.
--
Ville M. Vainio - vivainio.googlepages.com
blog=360.yahoo.com/villevainio - g[mail | talk]='vivainio'
More information about the IPython-dev
mailing list