[IPython-dev] Curly braces stripped from magic input

Greg Wilson gvwilson at third-bit.com
Tue Sep 3 20:49:26 EDT 2013


On 2013-09-02 12:29 AM, Fernando Perez wrote:
> Yes, it's weird and sub-optimal, and just a quirk of the historical
> path followed by the implementation.  While we've cleaned up a LOT of
> the magics machinery, there's always improvements to be done...
>
> The culprit here is this line of code:
>
> https://github.com/ipython/ipython/blob/master/IPython/core/interactiveshell.py#L2127
>
> where we call var_expand *unconditionally* outside the magic object
> itself.  So magics don't have a chance to know what the line before
> expansion looked like...
>
> I'd like to rewrite run_line_magic and run_cell_magic so they do even
> less and hand over the input as quickly as possible to the magics
> themselves. They can then decide whether to expand variables or not,
> and would have access to the original buffer.
>
> It's pretty straightforward to do, and would give us a clean and
> simple solution to situations like this.
>
> Fancy a PR, Greg? :)
>
Yup; I'll try to get something in tomorrow.
- G



More information about the IPython-dev mailing list