[IPython-user] Re: [IPython-dev] I need feedback: new escape for @magics?

Fernando Perez Fernando.Perez at colorado.edu
Wed Sep 29 17:04:04 CDT 2004


Prabhu Ramachandran wrote:
>>>>>>"FP" == Fernando Perez <Fernando.Perez at colorado.edu> writes:
> 
> 
>     FP> And for some odd reason, it's precisely that latex connection
>     FP> what makes me like it.  Don't really know why...
> 
>     FP> So I'm leaning towards %, but I'll gladly take votes/opinions
>     FP> on both...
> 
> % sounds good.  The only thing to keep in mind is, is it possible to
> use a magic in situations where '%' is not the first character?  From
> the discussions I assume not but are there future plans for requiring
> such a thing?

There isn't a really 'official' way to do so, but you can always do:

__IP.magic_foo('bar baz')

which is really what ipython does when you type

foo bar baz

at a prompt.  I may introduce an ipmagic() true python function, injected by 
ipython into __builtin__ at startup, to do this:

ipmagic('foo','bar baz')

which would expose this interface more cleanly.  This would give a user-level 
mechanism for calling magics anywhere without having to rely on name mangling 
tricks (which will not be valid for long, as I intend to clean that mess up soon).

Cheers,

f




More information about the IPython-user mailing list