[IPython-user] help about own magic
Ville M. Vainio
vivainio@gmail....
Sat Jan 5 03:13:11 CST 2008
On Jan 5, 2008 2:02 AM, Luc ORTEGA <luc.ortega@grenoble.cnrs.fr> wrote:
> def dotest(self, arg1, arg2, arg3, arg4):
> self.api.ex("test(%s , %f , %f , %s)" % (arg1,arg2,arg3,arg4))
>
> ip1.expose_magic('Mtest', dotest)
> TypeError: dotest() takes exactly 5 arguments (2 given)
This is exactly the problem. Magic functions take self, arg_s as
arguments, where arg_s is the whole string after the magic call. You
need to split the argument string yourself (perhaps using arg_split or
parse_options).
See %bookmark?? for an example on how to author a magic function.
--
Ville M. Vainio - vivainio.googlepages.com
blog=360.yahoo.com/villevainio - g[mail | talk]='vivainio'
More information about the IPython-user
mailing list