[IPython-dev] notebook %magic

Ralf Hemmecke hemmecke at gmail.com
Thu May 31 16:32:22 EDT 2012


> A bit more detail: that logic is delicate enough that in the recent
> big magics refactoring, I made the explicit decision to punt and
> hardcode '%%' as the cell magic prefix.

:-(

Although... %% is not as bad as % for me. But maybe I don't yet 
understand enough this magic business. I'll probably get back after 
reading some more code. If you were telling me that typing %pi at the 
beginning of an input (or output) line would be interpreted correctly as 
%pi (from fricas) and nothing else, then I'd be satisfied.

Anyway, if the ipython notebook should some day be able to be used as a
frontend for maple or mathematica then %, %% and %%% are bad, because of
their meaning inside the respective system.

> While one *could* in principle make the magic escapes configurable,
> there's a LOT of code in IPython by now where that is hardcoded,
> including multiple delicate regular expressions that are used on
> every single line of input.

Of course, I don't yet know the source code, but why wouldn't it be a 
feasible way to start the notebook code with something like

escapesequence='%$'
escaperegex='%\$'

and replace the 'delicate regular expressions' appropriately?

> I simply don't think it's realistic right now to make that
> configurable.

Yes, of course. It's open source and different people have different 
goals. No problem. Although... of course, I would be happier with a 
configurable escape mechanism.

Ralf



More information about the IPython-dev mailing list