[IPython-dev] splitter not transforming a line

Jason Grout jason-sage@creativetrax....
Tue Sep 25 07:43:18 CDT 2012


On 9/25/12 7:35 AM, Thomas Kluyver wrote:
> On 25 September 2012 13:22, Jason Grout <jason-sage@creativetrax.com> wrote:
>> Is this intentional?  There seem to be enough comments like
>> https://github.com/ipython/ipython/blob/master/IPython/core/inputsplitter.py#L883
>> that indicate that maybe this is an oversight in a tricky part of the code.
>
> It is quite possibly an oversight - all of that part of the code is
> complex. Sorry, my work on IPEP2 has been sidelined while I've been
> pushing Pylab forwards.
>
>> Since it is not complete and the buffer has the @interact line in it and
>> the @interact line does not end with ':' or ',', the transform is never
>> run.  This is a big problem for Sage, since Sage wants to transform that
>> 1 to Integer(1) in the preparser.
>
> Once it's in place, I would encourage you to do this with the new AST
> transformation hook:
> https://github.com/ipython/ipython/pull/2301
>
> This was inspired by Sympy wanting to do exactly the same
> transformation. I still need to do a bit of work, but I think I can
> see how to complete it.

Do you think the AST hook will make it into the next version, or should 
I submit a quick fix for this issue (i.e., check to see if buf[-1] 
starts with '@' as well as ends with ':' or ',').

We'll still have to do a string transformation since we introduce new 
syntax as well (e.g., [1..4] means [1,2,3,4]).  But many of our 
transforms will work more cleanly on an AST, so thanks for your work on 
this!

Jason



More information about the IPython-dev mailing list